Skip to content

Commit

Permalink
Fix syncing legacy FinampCollections.
Browse files Browse the repository at this point in the history
  • Loading branch information
Komodo5197 committed May 24, 2024
1 parent eb22e76 commit e681be0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
14 changes: 7 additions & 7 deletions lib/components/AlbumScreen/download_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ class DownloadDialog extends StatefulWidget {
viewId = finampUserHelper.currentUser!.currentViewId;
}
bool needTranscode = FinampSettingsHelper
.finampSettings.shouldTranscodeDownloads ==
TranscodeDownloadsSetting.ask &&
// Skip asking for transcode for image only collection
(item.finampCollection?.type != FinampCollectionType.libraryImages ||
// Skip asking for transcode for metadata +image collection
item.finampCollection?.type !=
FinampCollectionType.allPlaylistsMetadata);
.finampSettings.shouldTranscodeDownloads ==
TranscodeDownloadsSetting.ask &&
// Skip asking for transcode for image only collection
item.finampCollection?.type != FinampCollectionType.libraryImages ||
// Skip asking for transcode for metadata +image collection
item.finampCollection?.type !=
FinampCollectionType.allPlaylistsMetadata;
String? downloadLocation =
FinampSettingsHelper.finampSettings.defaultDownloadLocation;
if (!FinampSettingsHelper.finampSettings.downloadLocationsMap
Expand Down
21 changes: 17 additions & 4 deletions lib/models/finamp_models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ class FinampSettings {
this.showArtistChipImage = _showArtistChipImage,
this.trackOfflineFavorites = _trackOfflineFavoritesDefault,
this.showProgressOnNowPlayingBar = _showProgressOnNowPlayingBarDefault,
this.startInstantMixForIndividualTracks = _startInstantMixForIndividualTracksDefault,
this.startInstantMixForIndividualTracks =
_startInstantMixForIndividualTracksDefault,
});

@HiveField(0, defaultValue: _isOfflineDefault)
Expand Down Expand Up @@ -924,10 +925,22 @@ class DownloadStub {
BaseItemDto? _baseItemCached;

@ignore
FinampCollection? get finampCollection => _finampCollectionCached ??=
((jsonItem == null || type != DownloadItemType.finampCollection)
FinampCollection? get finampCollection =>
_finampCollectionCached ??= (type != DownloadItemType.finampCollection
? null
: FinampCollection.fromJson(jsonDecode(jsonItem!)));
: jsonItem == null
// Switch on ID to allow legacy collections to continue syncing
? switch (id) {
"Favorites" =>
FinampCollection(type: FinampCollectionType.favorites),
"All Playlists" =>
FinampCollection(type: FinampCollectionType.allPlaylists),
"5 Latest Albums" =>
FinampCollection(type: FinampCollectionType.latest5Albums),
_ =>
throw "Invalid FinampCollection DownloadItem: no attached collection"
}
: FinampCollection.fromJson(jsonDecode(jsonItem!)));

@ignore
FinampCollection? _finampCollectionCached;
Expand Down
13 changes: 1 addition & 12 deletions lib/services/downloads_service_backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1338,18 +1338,7 @@ class DownloadsSyncService {
Future<List<DownloadStub>> _getFinampCollectionChildren(
DownloadStub parent) async {
assert(parent.type == DownloadItemType.finampCollection);
FinampCollection collection;
// Switch on ID to allow legacy collections to continue syncing
switch (parent.id) {
case "Favorites":
collection = FinampCollection(type: FinampCollectionType.favorites);
case "All Playlists":
collection = FinampCollection(type: FinampCollectionType.allPlaylists);
case "5 Latest Albums":
collection = FinampCollection(type: FinampCollectionType.latest5Albums);
case _:
collection = parent.finampCollection!;
}
FinampCollection collection = parent.finampCollection!;
try {
List<BaseItemDto> outputItems;
DownloadItemType? typeOverride;
Expand Down

0 comments on commit e681be0

Please sign in to comment.