mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-08 00:51:20 +00:00
chore: Rename '_getApiToken' to 'get _token' for GraphQL API map
This commit is contained in:
parent
08f3258615
commit
27aaf93838
|
@ -74,13 +74,11 @@ abstract class GraphQLApiMap {
|
||||||
defaultHeaders: {'Accept-Language': _locale},
|
defaultHeaders: {'Accept-Language': _locale},
|
||||||
);
|
);
|
||||||
|
|
||||||
final String token = _getApiToken();
|
|
||||||
|
|
||||||
final Link graphQLLink = RequestLoggingLink().concat(
|
final Link graphQLLink = RequestLoggingLink().concat(
|
||||||
isWithToken
|
isWithToken
|
||||||
? AuthLink(
|
? AuthLink(
|
||||||
getToken: () async =>
|
getToken: () async =>
|
||||||
customToken == '' ? 'Bearer $token' : customToken,
|
customToken == '' ? 'Bearer $_token' : customToken,
|
||||||
).concat(httpLink)
|
).concat(httpLink)
|
||||||
: httpLink,
|
: httpLink,
|
||||||
);
|
);
|
||||||
|
@ -96,16 +94,14 @@ abstract class GraphQLApiMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<GraphQLClient> getSubscriptionClient() async {
|
Future<GraphQLClient> getSubscriptionClient() async {
|
||||||
final String token = _getApiToken();
|
|
||||||
|
|
||||||
final WebSocketLink webSocketLink = WebSocketLink(
|
final WebSocketLink webSocketLink = WebSocketLink(
|
||||||
'ws://api.$rootAddress/graphql',
|
'ws://api.$rootAddress/graphql',
|
||||||
config: SocketClientConfig(
|
config: SocketClientConfig(
|
||||||
autoReconnect: true,
|
autoReconnect: true,
|
||||||
headers: token.isEmpty
|
headers: _token.isEmpty
|
||||||
? null
|
? null
|
||||||
: {
|
: {
|
||||||
'Authorization': 'Bearer $token',
|
'Authorization': 'Bearer $_token',
|
||||||
'Accept-Language': _locale,
|
'Accept-Language': _locale,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -119,7 +115,7 @@ abstract class GraphQLApiMap {
|
||||||
|
|
||||||
String get _locale => getIt.get<ApiConfigModel>().localeCode ?? 'en';
|
String get _locale => getIt.get<ApiConfigModel>().localeCode ?? 'en';
|
||||||
|
|
||||||
String _getApiToken() {
|
String get _token {
|
||||||
String token = '';
|
String token = '';
|
||||||
final serverDetails = getIt<ApiConfigModel>().serverDetails;
|
final serverDetails = getIt<ApiConfigModel>().serverDetails;
|
||||||
if (serverDetails != null) {
|
if (serverDetails != null) {
|
||||||
|
|
Loading…
Reference in a new issue