From e76ee468aa9a5f37ceee9481e2b63c5d30202c00 Mon Sep 17 00:00:00 2001 From: Feichtmeier Date: Mon, 25 Nov 2024 23:17:38 +0100 Subject: [PATCH] chore: remove unused code --- lib/compute_isolate.dart | 35 ------------------------ lib/extensions/country_x.dart | 3 -- lib/local_audio/local_cover_service.dart | 13 +-------- lib/settings/settings_service.dart | 1 - 4 files changed, 1 insertion(+), 51 deletions(-) delete mode 100644 lib/compute_isolate.dart diff --git a/lib/compute_isolate.dart b/lib/compute_isolate.dart deleted file mode 100644 index f3a8c6cb8..000000000 --- a/lib/compute_isolate.dart +++ /dev/null @@ -1,35 +0,0 @@ -import 'dart:isolate'; - -import 'package:flutter/services.dart'; - -Future computeIsolate(Future Function() function) async { - final receivePort = ReceivePort(); - var rootToken = RootIsolateToken.instance!; - await Isolate.spawn<_IsolateData>( - _isolateEntry, - _IsolateData( - token: rootToken, - function: function, - answerPort: receivePort.sendPort, - ), - ); - return receivePort.first; -} - -void _isolateEntry(_IsolateData isolateData) async { - BackgroundIsolateBinaryMessenger.ensureInitialized(isolateData.token); - final answer = await isolateData.function(); - isolateData.answerPort.send(answer); -} - -class _IsolateData { - final RootIsolateToken token; - final Function function; - final SendPort answerPort; - - _IsolateData({ - required this.token, - required this.function, - required this.answerPort, - }); -} diff --git a/lib/extensions/country_x.dart b/lib/extensions/country_x.dart index 6c541c106..afdeeddf7 100644 --- a/lib/extensions/country_x.dart +++ b/lib/extensions/country_x.dart @@ -1,7 +1,6 @@ import 'package:podcast_search/podcast_search.dart'; import '../l10n/l10n.dart'; -import 'string_x.dart'; extension CountryX on Country { String localize(AppLocalizations l10n) => switch (this) { @@ -262,7 +261,5 @@ extension CountryX on Country { Country.yemen => l10n.regionYemen, Country.zambia => l10n.regionZambia, Country.zimbabwe => l10n.regionZimbabwe, - // ignore: unreachable_switch_case - _ => name.camelToSentence.everyWordCapitalized, }; } diff --git a/lib/local_audio/local_cover_service.dart b/lib/local_audio/local_cover_service.dart index 7382a6b46..66d24b6e5 100644 --- a/lib/local_audio/local_cover_service.dart +++ b/lib/local_audio/local_cover_service.dart @@ -6,15 +6,11 @@ import 'package:path/path.dart' as p; import 'package:audio_metadata_reader/audio_metadata_reader.dart'; import 'package:collection/collection.dart'; -import '../compute_isolate.dart'; -import '../constants.dart'; -import '../persistence_utils.dart'; - class LocalCoverService { final _propertiesChangedController = StreamController.broadcast(); Stream get propertiesChanged => _propertiesChangedController.stream; - var _store = {}; + final _store = {}; int get storeLength => _store.length; Future getCover({ @@ -66,12 +62,5 @@ class LocalCoverService { Uint8List? get(String? albumId) => albumId == null ? null : _store[albumId]; - Future write() async => writeUint8ListMap(_store, kCoverStore); - - // This does not make much sense except for small libs, where the store is filled - // fast anyways. Let's keep it for eventual use... - Future read() async => - _store = await computeIsolate(() => readUint8ListMap(kCoverStore)) ?? []; - Future dispose() async => _propertiesChangedController.close(); } diff --git a/lib/settings/settings_service.dart b/lib/settings/settings_service.dart index 1ac85ba60..76f50f4e2 100644 --- a/lib/settings/settings_service.dart +++ b/lib/settings/settings_service.dart @@ -70,7 +70,6 @@ class SettingsService { void setEnableDiscordRPC(bool value) => _preferences.setBool(kEnableDiscordRPC, value).then(notify); - // TODO: check how this increases cpu usage bool get useMoreAnimations => _preferences.getBool(kUseMoreAnimations) ?? !Platform.isLinux; void setUseMoreAnimations(bool value) =>