diff --git a/android/app/src/main/java/com/audiobookshelf/app/data/DbManager.kt b/android/app/src/main/java/com/audiobookshelf/app/data/DbManager.kt index 20cac976..f7da6233 100644 --- a/android/app/src/main/java/com/audiobookshelf/app/data/DbManager.kt +++ b/android/app/src/main/java/com/audiobookshelf/app/data/DbManager.kt @@ -213,7 +213,11 @@ class DbManager { val localLibraryItems = getLocalLibraryItems() localMediaProgress.forEach { val matchingLLI = localLibraryItems.find { lli -> lli.id == it.localLibraryItemId } - if (matchingLLI == null) { + if (!it.id.startsWith("local")) { + // A bug on the server when syncing local media progress was replacing the media progress id causing duplicate progress. Remove them. + Log.d(tag, "cleanLocalMediaProgress: Invalid local media progress does not start with 'local' (fixed on server 2.0.24)") + Paper.book("localMediaProgress").delete(it.id) + } else if (matchingLLI == null) { Log.d(tag, "cleanLocalMediaProgress: No matching local library item for local media progress ${it.id} - removing") Paper.book("localMediaProgress").delete(it.id) } else if (matchingLLI.isPodcast) { diff --git a/layouts/default.vue b/layouts/default.vue index 68a10886..97420d4d 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -66,9 +66,6 @@ export default { }, currentLibraryId() { return this.$store.state.libraries.currentLibraryId - }, - isSocketConnected() { - return this.$store.state.socketConnected } }, methods: { @@ -174,6 +171,7 @@ export default { async syncLocalMediaProgress() { if (!this.user) { console.log('[default] No need to sync local media progress - not connected to server') + this.$store.commit('setLastLocalMediaSyncResults', null) return } @@ -181,10 +179,15 @@ export default { var response = await this.$db.syncLocalMediaProgressWithServer() if (!response) { if (this.$platform != 'web') this.$toast.error('Failed to sync local media with server') + this.$store.commit('setLastLocalMediaSyncResults', null) return } const { numLocalMediaProgressForServer, numServerProgressUpdates, numLocalProgressUpdates } = response if (numLocalMediaProgressForServer > 0) { + response.syncedAt = Date.now() + response.serverConfigName = this.$store.getters['user/getServerConfigName'] + this.$store.commit('setLastLocalMediaSyncResults', response) + if (numServerProgressUpdates > 0 || numLocalProgressUpdates > 0) { console.log(`[default] ${numServerProgressUpdates} Server progress updates | ${numLocalProgressUpdates} Local progress updates`) } else { @@ -192,6 +195,7 @@ export default { } } else { console.log('[default] syncLocalMediaProgress No local media progress to sync') + this.$store.commit('setLastLocalMediaSyncResults', null) } }, async userUpdated(user) { diff --git a/pages/localMedia/folders/index.vue b/pages/localMedia/folders/index.vue index 00029bef..d6b09ce4 100644 --- a/pages/localMedia/folders/index.vue +++ b/pages/localMedia/folders/index.vue @@ -1,5 +1,28 @@