From 79e27578e54aecbf3b9797cf8fe12a05d16a69b7 Mon Sep 17 00:00:00 2001 From: Hugh Daschbach Date: Thu, 14 Jul 2022 04:12:30 -0700 Subject: [PATCH] Fix issue #124 - empty queue on restart. The Gson deserializer required parameter is a reader object. It silently fails when passed a string. --- .../main/java/audio/funkwhale/ffa/playback/QueueManager.kt | 2 +- .../audio/funkwhale/ffa/repositories/AlbumsRepository.kt | 2 +- .../funkwhale/ffa/repositories/ArtistTracksRepository.kt | 2 +- .../audio/funkwhale/ffa/repositories/ArtistsRepository.kt | 2 +- .../audio/funkwhale/ffa/repositories/FavoritesRepository.kt | 4 ++-- .../funkwhale/ffa/repositories/PlaylistTracksRepository.kt | 2 +- .../audio/funkwhale/ffa/repositories/PlaylistsRepository.kt | 4 ++-- .../audio/funkwhale/ffa/repositories/RadiosRepository.kt | 2 +- .../audio/funkwhale/ffa/repositories/SearchRepository.kt | 6 +++--- .../audio/funkwhale/ffa/repositories/TracksRepository.kt | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/audio/funkwhale/ffa/playback/QueueManager.kt b/app/src/main/java/audio/funkwhale/ffa/playback/QueueManager.kt index d771f1b..fe9bf31 100644 --- a/app/src/main/java/audio/funkwhale/ffa/playback/QueueManager.kt +++ b/app/src/main/java/audio/funkwhale/ffa/playback/QueueManager.kt @@ -29,7 +29,7 @@ class QueueManager(val context: Context) { init { FFACache.getLine(context, "queue")?.let { json -> - gsonDeserializerOf(QueueCache::class.java).deserialize(json)?.let { cache -> + gsonDeserializerOf(QueueCache::class.java).deserialize(json.reader())?.let { cache -> metadata = cache.data.toMutableList() val factory = cacheDataSourceFactoryProvider.create(context) diff --git a/app/src/main/java/audio/funkwhale/ffa/repositories/AlbumsRepository.kt b/app/src/main/java/audio/funkwhale/ffa/repositories/AlbumsRepository.kt index 7d81ed4..cb43081 100644 --- a/app/src/main/java/audio/funkwhale/ffa/repositories/AlbumsRepository.kt +++ b/app/src/main/java/audio/funkwhale/ffa/repositories/AlbumsRepository.kt @@ -35,5 +35,5 @@ class AlbumsRepository(override val context: Context?, artistId: Int? = null) : override fun cache(data: List) = AlbumsCache(data) override fun uncache(json: String) = - gsonDeserializerOf(AlbumsCache::class.java).deserialize(json) + gsonDeserializerOf(AlbumsCache::class.java).deserialize(json.reader()) } diff --git a/app/src/main/java/audio/funkwhale/ffa/repositories/ArtistTracksRepository.kt b/app/src/main/java/audio/funkwhale/ffa/repositories/ArtistTracksRepository.kt index e1e155f..673ab8b 100644 --- a/app/src/main/java/audio/funkwhale/ffa/repositories/ArtistTracksRepository.kt +++ b/app/src/main/java/audio/funkwhale/ffa/repositories/ArtistTracksRepository.kt @@ -27,5 +27,5 @@ class ArtistTracksRepository(override val context: Context?, private val artistI override fun cache(data: List) = TracksCache(data) override fun uncache(json: String) = - gsonDeserializerOf(TracksCache::class.java).deserialize(json) + gsonDeserializerOf(TracksCache::class.java).deserialize(json.reader()) } diff --git a/app/src/main/java/audio/funkwhale/ffa/repositories/ArtistsRepository.kt b/app/src/main/java/audio/funkwhale/ffa/repositories/ArtistsRepository.kt index f232a51..ea551dc 100644 --- a/app/src/main/java/audio/funkwhale/ffa/repositories/ArtistsRepository.kt +++ b/app/src/main/java/audio/funkwhale/ffa/repositories/ArtistsRepository.kt @@ -26,5 +26,5 @@ class ArtistsRepository(override val context: Context?) : Repository) = ArtistsCache(data) override fun uncache(json: String) = - gsonDeserializerOf(ArtistsCache::class.java).deserialize(json) + gsonDeserializerOf(ArtistsCache::class.java).deserialize(json.reader()) } diff --git a/app/src/main/java/audio/funkwhale/ffa/repositories/FavoritesRepository.kt b/app/src/main/java/audio/funkwhale/ffa/repositories/FavoritesRepository.kt index 0100b95..bc99c11 100644 --- a/app/src/main/java/audio/funkwhale/ffa/repositories/FavoritesRepository.kt +++ b/app/src/main/java/audio/funkwhale/ffa/repositories/FavoritesRepository.kt @@ -34,7 +34,7 @@ class FavoritesRepository(override val context: Context?) : Repository) = TracksCache(data) override fun uncache(json: String) = - gsonDeserializerOf(TracksCache::class.java).deserialize(json) + gsonDeserializerOf(TracksCache::class.java).deserialize(json.reader()) private val favoritedRepository = FavoritedRepository(context!!) @@ -115,7 +115,7 @@ class FavoritedRepository(override val context: Context?) : Repository) = FavoritedCache(data) override fun uncache(json: String) = - gsonDeserializerOf(FavoritedCache::class.java).deserialize(json) + gsonDeserializerOf(FavoritedCache::class.java).deserialize(json.reader()) fun update(context: Context?, scope: CoroutineScope) { fetch(Origin.Network.origin).untilNetwork(scope, IO) { favorites, _, _, _ -> diff --git a/app/src/main/java/audio/funkwhale/ffa/repositories/PlaylistTracksRepository.kt b/app/src/main/java/audio/funkwhale/ffa/repositories/PlaylistTracksRepository.kt index 8e53ea0..7aba93b 100644 --- a/app/src/main/java/audio/funkwhale/ffa/repositories/PlaylistTracksRepository.kt +++ b/app/src/main/java/audio/funkwhale/ffa/repositories/PlaylistTracksRepository.kt @@ -30,7 +30,7 @@ class PlaylistTracksRepository(override val context: Context?, playlistId: Int) override fun cache(data: List) = PlaylistTracksCache(data) override fun uncache(json: String) = - gsonDeserializerOf(PlaylistTracksCache::class.java).deserialize(json) + gsonDeserializerOf(PlaylistTracksCache::class.java).deserialize(json.reader()) override fun onDataFetched(data: List): List = runBlocking { val favorites = FavoritedRepository(context).fetch(Origin.Network.origin) diff --git a/app/src/main/java/audio/funkwhale/ffa/repositories/PlaylistsRepository.kt b/app/src/main/java/audio/funkwhale/ffa/repositories/PlaylistsRepository.kt index 8ec5a0f..3b59d2c 100644 --- a/app/src/main/java/audio/funkwhale/ffa/repositories/PlaylistsRepository.kt +++ b/app/src/main/java/audio/funkwhale/ffa/repositories/PlaylistsRepository.kt @@ -30,7 +30,7 @@ class PlaylistsRepository(override val context: Context?) : Repository) = PlaylistsCache(data) override fun uncache(json: String) = - gsonDeserializerOf(PlaylistsCache::class.java).deserialize(json) + gsonDeserializerOf(PlaylistsCache::class.java).deserialize(json.reader()) } class ManagementPlaylistsRepository(override val context: Context?) : @@ -50,7 +50,7 @@ class ManagementPlaylistsRepository(override val context: Context?) : override fun cache(data: List) = PlaylistsCache(data) override fun uncache(json: String) = - gsonDeserializerOf(PlaylistsCache::class.java).deserialize(json) + gsonDeserializerOf(PlaylistsCache::class.java).deserialize(json.reader()) suspend fun new(name: String): Int? { context?.let { diff --git a/app/src/main/java/audio/funkwhale/ffa/repositories/RadiosRepository.kt b/app/src/main/java/audio/funkwhale/ffa/repositories/RadiosRepository.kt index 7e398d1..7118ac7 100644 --- a/app/src/main/java/audio/funkwhale/ffa/repositories/RadiosRepository.kt +++ b/app/src/main/java/audio/funkwhale/ffa/repositories/RadiosRepository.kt @@ -26,7 +26,7 @@ class RadiosRepository(override val context: Context?) : Repository) = RadiosCache(data) override fun uncache(json: String) = - gsonDeserializerOf(RadiosCache::class.java).deserialize(json) + gsonDeserializerOf(RadiosCache::class.java).deserialize(json.reader()) override fun onDataFetched(data: List): List { return data diff --git a/app/src/main/java/audio/funkwhale/ffa/repositories/SearchRepository.kt b/app/src/main/java/audio/funkwhale/ffa/repositories/SearchRepository.kt index bb4d46b..a93ceb9 100644 --- a/app/src/main/java/audio/funkwhale/ffa/repositories/SearchRepository.kt +++ b/app/src/main/java/audio/funkwhale/ffa/repositories/SearchRepository.kt @@ -34,7 +34,7 @@ class TracksSearchRepository(override val context: Context?, var query: String) override fun cache(data: List) = TracksCache(data) override fun uncache(json: String) = - gsonDeserializerOf(TracksCache::class.java).deserialize(json) + gsonDeserializerOf(TracksCache::class.java).deserialize(json.reader()) override fun onDataFetched(data: List): List = runBlocking { val favorites = FavoritedRepository(context).fetch(Origin.Cache.origin) @@ -76,7 +76,7 @@ class ArtistsSearchRepository(override val context: Context?, var query: String) override fun cache(data: List) = ArtistsCache(data) override fun uncache(json: String) = - gsonDeserializerOf(ArtistsCache::class.java).deserialize(json) + gsonDeserializerOf(ArtistsCache::class.java).deserialize(json.reader()) } class AlbumsSearchRepository(override val context: Context?, var query: String) : @@ -96,5 +96,5 @@ class AlbumsSearchRepository(override val context: Context?, var query: String) override fun cache(data: List) = AlbumsCache(data) override fun uncache(json: String) = - gsonDeserializerOf(AlbumsCache::class.java).deserialize(json) + gsonDeserializerOf(AlbumsCache::class.java).deserialize(json.reader()) } diff --git a/app/src/main/java/audio/funkwhale/ffa/repositories/TracksRepository.kt b/app/src/main/java/audio/funkwhale/ffa/repositories/TracksRepository.kt index 4eb3dd4..7df3af2 100644 --- a/app/src/main/java/audio/funkwhale/ffa/repositories/TracksRepository.kt +++ b/app/src/main/java/audio/funkwhale/ffa/repositories/TracksRepository.kt @@ -38,7 +38,7 @@ class TracksRepository(override val context: Context?, albumId: Int) : override fun cache(data: List) = TracksCache(data) override fun uncache(json: String) = - gsonDeserializerOf(TracksCache::class.java).deserialize(json) + gsonDeserializerOf(TracksCache::class.java).deserialize(json.reader()) companion object { fun getDownloadedIds(exoDownloadManager: DownloadManager): List? {