From 62091a02a3579a34e7a55aabbf99f2c5e573d2a1 Mon Sep 17 00:00:00 2001 From: Artem Anufrij Date: Tue, 19 Sep 2023 15:00:48 +0200 Subject: [PATCH] reset progress if album is finished --- src/components/Player.vue | 8 +++++--- src/components/dialogs/AlbumViewer.vue | 1 - src/store/modules/user/actions.js | 10 +++++++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/components/Player.vue b/src/components/Player.vue index e8ee84d..78fdd3a 100644 --- a/src/components/Player.vue +++ b/src/components/Player.vue @@ -203,7 +203,9 @@ export default { this.audio.play(); } }, - reset() { + reset(container) { + this.$store.dispatch("user/resetProgress", container); + window.clearInterval(this.intervalProgress); window.clearInterval(this.intervalState); if (!this.audio.paused) { @@ -370,11 +372,11 @@ export default { this.reset(); } }, - selectedTrack(newVal) { + selectedTrack(newVal, oldVal) { if (newVal._id) { this.playTrack(newVal); } else { - this.reset(); + this.reset(oldVal); } }, }, diff --git a/src/components/dialogs/AlbumViewer.vue b/src/components/dialogs/AlbumViewer.vue index a4c8cac..83f4e08 100644 --- a/src/components/dialogs/AlbumViewer.vue +++ b/src/components/dialogs/AlbumViewer.vue @@ -216,7 +216,6 @@ export default { this.$store.dispatch("albums/shareDisable", this.selectedAlbum); }, loadUserProgress() { - console.log(this.selectedTrack); if (this.selectedTrack.parent._id != this.selectedAlbum._id) this.$store.dispatch("user/getProgress", this.selectedAlbum); } diff --git a/src/store/modules/user/actions.js b/src/store/modules/user/actions.js index 121949e..53348f3 100644 --- a/src/store/modules/user/actions.js +++ b/src/store/modules/user/actions.js @@ -84,7 +84,8 @@ export default { if (context.state._id == -1) { return; } - axios.post(context.rootGetters.server + "/api/user/progress", item, context.rootGetters.headers); + axios + .post(context.rootGetters.server + "/api/user/progress", item, context.rootGetters.headers); }, getProgress(context, parent) { if (context.state._id == -1) { @@ -97,6 +98,13 @@ export default { parent.progress = res.data; }); }, + resetProgress(context, item) { + if (context.state._id == -1) { + return; + } + axios + .delete(context.rootGetters.server + "/api/user/progress/" + item.album_id, context.rootGetters.headers); + }, savePlayerSettings(context) { let body = { repeat: context.rootGetters["player/repeatType"],