Skip to content

Commit

Permalink
review findings
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaphasilor committed Nov 8, 2024
1 parent 248b028 commit 0692226
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Future<void> _setupDownloadsHelper() async {
final downloadsService = GetIt.instance<DownloadsService>();

if (!FinampSettingsHelper
.finampSettings.hasCompleteddownloadsServiceMigration) {
.finampSettings.hasCompletedDownloadsServiceMigration) {
await downloadsService.migrateFromHive();
FinampSettingsHelper.setHasCompleteddownloadsServiceMigration(true);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/models/finamp_models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class FinampSettings {
this.autoloadLastQueueOnStartup = _autoLoadLastQueueOnStartup,
this.hasCompletedBlurhashImageMigration = true,
this.hasCompletedBlurhashImageMigrationIdFix = true,
this.hasCompleteddownloadsServiceMigration = false,
this.hasCompletedDownloadsServiceMigration = true,
this.requireWifiForDownloads = false,
this.onlyShowFullyDownloaded = false,
this.showDownloadsWithUnknownLibrary = true,
Expand Down Expand Up @@ -212,7 +212,7 @@ class FinampSettings {
_showSeekControlsOnMediaNotificationDefault,
this.keepScreenOnOption = _keepScreenOnOption,
this.keepScreenOnWhilePluggedIn = _keepScreenOnWhilePluggedIn,
this.hasDownloadedPlaylistInfo = false,
this.hasDownloadedPlaylistInfo = _hasDownloadedPlaylistInfoDefault,
this.transcodingSegmentContainer = _defaultTranscodingSegmentContainer,
this.featureChipsConfiguration = _featureChipsConfigurationDefault});

Expand Down Expand Up @@ -328,7 +328,7 @@ class FinampSettings {
VolumeNormalizationMode volumeNormalizationMode;

@HiveField(34, defaultValue: false)
bool hasCompleteddownloadsServiceMigration;
bool hasCompletedDownloadsServiceMigration;

@HiveField(35, defaultValue: false)
bool requireWifiForDownloads;
Expand Down
11 changes: 7 additions & 4 deletions lib/models/finamp_models.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions lib/screens/music_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import '../services/finamp_settings_helper.dart';
import '../services/finamp_user_helper.dart';
import '../services/jellyfin_api_helper.dart';

final _musicScreenLogger = Logger("MusicScreen");

void postLaunchHook(WidgetRef ref) async {
final downloadsService = GetIt.instance<DownloadsService>();
final queueService = GetIt.instance<QueueService>();
Expand All @@ -35,7 +37,10 @@ void postLaunchHook(WidgetRef ref) async {
FinampCollection(type: FinampCollectionType.allPlaylistsMetadata)),
null);
if (status.isRequired == false) {
await downloadsService.addDefaultPlaylistInfoDownload();
await downloadsService.addDefaultPlaylistInfoDownload().catchError((e) {
// log error without snackbar, we don't want users to be greeted with errors on first launch
_musicScreenLogger.severe("Failed to download playlist metadata: $e");
});
}
FinampSettingsHelper.setHasDownloadedPlaylistInfo(true);
}
Expand All @@ -61,7 +66,6 @@ class _MusicScreenState extends ConsumerState<MusicScreen>
bool _showShuffleFab = false;
TextEditingController textEditingController = TextEditingController();
String? searchQuery;
final _musicScreenLogger = Logger("MusicScreen");
final Map<TabContentType, MusicRefreshCallback> refreshMap = {};

TabController? _tabController;
Expand Down
10 changes: 1 addition & 9 deletions lib/services/downloads_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1234,15 +1234,7 @@ class DownloadsService {
.containsKey(downloadLocation)) {
downloadLocation = null;
}
if (downloadLocation == null) {
var locations = FinampSettingsHelper
.finampSettings.downloadLocationsMap.values
.where((element) =>
element.baseDirectory != DownloadLocationType.internalDocuments);
if (locations.length == 1) {
downloadLocation = locations.first.id;
}
}
downloadLocation ??= FinampSettingsHelper.finampSettings.internalSongDir.id;

// Automatically download playlist metadata (to enhance the playlist actions dialog and offline mode)
await addDownload(
Expand Down
2 changes: 1 addition & 1 deletion lib/services/finamp_settings_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class FinampSettingsHelper {
static void setHasCompleteddownloadsServiceMigration(
bool hasCompleteddownloadsServiceMigration) {
FinampSettings finampSettingsTemp = finampSettings;
finampSettingsTemp.hasCompleteddownloadsServiceMigration =
finampSettingsTemp.hasCompletedDownloadsServiceMigration =
hasCompleteddownloadsServiceMigration;
Hive.box<FinampSettings>("FinampSettings")
.put("FinampSettings", finampSettingsTemp);
Expand Down

0 comments on commit 0692226

Please sign in to comment.