mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 13:55:58 +00:00
fix(library): hide the Favorites soundtrack collection until it has a track
This commit is contained in:
3 files changed
+15
-3
No files matched your search
@@ -177,9 +177,10 @@ object SoundtrackCollections {
|
|||||||
source = Library.SOURCE_COLLECTION, soundtrack = true,
|
source = Library.SOURCE_COLLECTION, soundtrack = true,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun games(context: Context, favoritesLabel: String): List<Library.SteamGame> {
|
fun games(context: Context, favoritesLabel: String, skipEmptyFavorites: Boolean = false): List<Library.SteamGame> {
|
||||||
val s = snapshot
|
val s = snapshot
|
||||||
return listOf(game(context, FAVORITES_ID, favoritesLabel, s.favorites)) + s.collections.map { game(context, it.id, it.name, it.tracks) }
|
val favorites = if (skipEmptyFavorites && s.favorites.isEmpty()) emptyList() else listOf(game(context, FAVORITES_ID, favoritesLabel, s.favorites))
|
||||||
|
return favorites + s.collections.map { game(context, it.id, it.name, it.tracks) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun album(context: Context, id: Int): Soundtrack.Album {
|
fun album(context: Context, id: Int): Soundtrack.Album {
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ internal fun LibraryPage(s: FrontEndState, a: FrontEndActions, selected: String,
|
|||||||
val favoritesLabel = stringResource(R.string.soundtracks_favorites)
|
val favoritesLabel = stringResource(R.string.soundtracks_favorites)
|
||||||
val all = remember(soundMode, s.steamGames, s.soundtracks, s.soundtracksEnabled, cloudRows, owned, installedStore, savedSnapshot, favoritesLabel) {
|
val all = remember(soundMode, s.steamGames, s.soundtracks, s.soundtracksEnabled, cloudRows, owned, installedStore, savedSnapshot, favoritesLabel) {
|
||||||
if (soundMode) s.soundtracks.map { LibraryEntry("sound:${it.appId}", it.source, it.name, it, null, true) } +
|
if (soundMode) s.soundtracks.map { LibraryEntry("sound:${it.appId}", it.source, it.name, it, null, true) } +
|
||||||
(if (s.soundtracks.isEmpty() && savedSnapshot.favorites.isEmpty() && savedSnapshot.collections.isEmpty()) emptyList() else SoundtrackCollections.games(ctx, favoritesLabel))
|
(if (s.soundtracks.isEmpty() && savedSnapshot.favorites.isEmpty() && savedSnapshot.collections.isEmpty()) emptyList() else SoundtrackCollections.games(ctx, favoritesLabel, skipEmptyFavorites = true))
|
||||||
.map { LibraryEntry("sound:${it.appId}", it.source, it.name, it, null, true) }
|
.map { LibraryEntry("sound:${it.appId}", it.source, it.name, it, null, true) }
|
||||||
else libraryEntries(s.steamGames + cloudRows + if (s.soundtracksEnabled) emptyList() else s.soundtracks.filter { it.library != Library.ADDED }, owned, installedStore)
|
else libraryEntries(s.steamGames + cloudRows + if (s.soundtracksEnabled) emptyList() else s.soundtracks.filter { it.library != Library.ADDED }, owned, installedStore)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,4 +40,15 @@ class SoundtrackCollectionsTest {
|
|||||||
val list = listOf(Collection(2_000_000_005, "x", emptyList()))
|
val list = listOf(Collection(2_000_000_005, "x", emptyList()))
|
||||||
assertEquals(2_000_000_006, SoundtrackCollections.nextId(list))
|
assertEquals(2_000_000_006, SoundtrackCollections.nextId(list))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test fun emptyFavoritesCanBeLeftOutOfTheLibraryList() {
|
||||||
|
val context = androidx.test.core.app.ApplicationProvider.getApplicationContext<android.content.Context>()
|
||||||
|
SoundtrackCollections.load(context)
|
||||||
|
SoundtrackCollections.create(context, "Chill", emptyList())
|
||||||
|
val ids = { skip: Boolean -> SoundtrackCollections.games(context, "Favorites", skip).map { it.appId } }
|
||||||
|
assertTrue(SoundtrackCollections.FAVORITES_ID in ids(false))
|
||||||
|
assertFalse(SoundtrackCollections.FAVORITES_ID in ids(true))
|
||||||
|
SoundtrackCollections.add(context, SoundtrackCollections.FAVORITES_ID, listOf(ref("a")))
|
||||||
|
assertTrue(SoundtrackCollections.FAVORITES_ID in ids(true))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user