Skip to content

Commit

Permalink
simplify server constructor
Browse files Browse the repository at this point in the history
remove drone file
  • Loading branch information
lamarios committed Sep 15, 2024
1 parent a87c224 commit da12a68
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 99 deletions.
83 changes: 0 additions & 83 deletions .drone.yml

This file was deleted.

32 changes: 16 additions & 16 deletions lib/service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,16 @@ const imgurClientId = 'Client-ID 2cfbc27ce77879d';
const maxPing = 9007199254740991;

class Service {
final log;
final log = Logger('Service');
final Client httpClient;

Service() :
log = Logger('Service'),
httpClient = Platform.isAndroid ?
CronetClient.fromCronetEngine(
CronetEngine.build(
cacheMode: CacheMode.memory,
cacheMaxSize: 2 * 1024 * 1024),
closeEngine: true) :
http.Client();
Service()
: httpClient = Platform.isAndroid
? CronetClient.fromCronetEngine(
CronetEngine.build(
cacheMode: CacheMode.memory, cacheMaxSize: 2 * 1024 * 1024),
closeEngine: true)
: http.Client();

String urlFormatForLog(Uri? uri) {
return kDebugMode ? uri.toString() : '${uri?.replace(host: 'xxxxxxxxxx')}';
Expand Down Expand Up @@ -413,7 +411,8 @@ class Service {
if (query.isEmpty) return SearchSuggestion(query, []);
var request = await buildRequest(urlSearchSuggestions,
query: {"q": Uri.encodeQueryComponent(query)});
final response = await httpClient.get(request.uri, headers: request.headers);
final response =
await httpClient.get(request.uri, headers: request.headers);
SearchSuggestion search =
SearchSuggestion.fromJson(handleResponse(response));
if (search.suggestions.any((element) => element.contains(";"))) {
Expand Down Expand Up @@ -638,8 +637,8 @@ class Service {

log.info(jsonEncode(body));

final response =
await httpClient.post(req.uri, headers: req.headers, body: jsonEncode(body));
final response = await httpClient.post(req.uri,
headers: req.headers, body: jsonEncode(body));
Map<String, dynamic> playlist = handleResponse(response);
return playlist['playlistId'] as String;
}
Expand All @@ -652,8 +651,8 @@ class Service {
'videoId': videoId,
};

final response =
await httpClient.post(req.uri, headers: req.headers, body: jsonEncode(body));
final response = await httpClient.post(req.uri,
headers: req.headers, body: jsonEncode(body));
handleResponse(response);
}

Expand Down Expand Up @@ -744,7 +743,8 @@ class Service {
}

Future<List<InvidiousPublicServer>> getPublicServers() async {
final response = await httpClient.get(Uri.parse(urlGetInvidiousPublicServers));
final response =
await httpClient.get(Uri.parse(urlGetInvidiousPublicServers));
List<InvidiousPublicServer> servers = [];
Iterable i = handleResponse(response);

Expand Down
1 change: 1 addition & 0 deletions linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
jni
)

set(PLUGIN_BUNDLED_LIBRARIES)
Expand Down
1 change: 1 addition & 0 deletions windows/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
jni
)

set(PLUGIN_BUNDLED_LIBRARIES)
Expand Down

0 comments on commit da12a68

Please sign in to comment.