save-and-restore-progress-for-audio fix #10 #16

Merged
artem merged 8 commits from save-and-restore-progress-for-audio into main 2023-09-19 16:34:57 +02:00
3 changed files with 14 additions and 5 deletions
Showing only changes of commit 62091a02a3 - Show all commits

View File

@ -203,7 +203,9 @@ export default {
this.audio.play(); this.audio.play();
} }
}, },
reset() { reset(container) {
this.$store.dispatch("user/resetProgress", container);
window.clearInterval(this.intervalProgress); window.clearInterval(this.intervalProgress);
window.clearInterval(this.intervalState); window.clearInterval(this.intervalState);
if (!this.audio.paused) { if (!this.audio.paused) {
@ -370,11 +372,11 @@ export default {
this.reset(); this.reset();
} }
}, },
selectedTrack(newVal) { selectedTrack(newVal, oldVal) {
if (newVal._id) { if (newVal._id) {
this.playTrack(newVal); this.playTrack(newVal);
} else { } else {
this.reset(); this.reset(oldVal);
} }
}, },
}, },

View File

@ -216,7 +216,6 @@ export default {
this.$store.dispatch("albums/shareDisable", this.selectedAlbum); this.$store.dispatch("albums/shareDisable", this.selectedAlbum);
}, },
loadUserProgress() { loadUserProgress() {
console.log(this.selectedTrack);
if (this.selectedTrack.parent._id != this.selectedAlbum._id) if (this.selectedTrack.parent._id != this.selectedAlbum._id)
this.$store.dispatch("user/getProgress", this.selectedAlbum); this.$store.dispatch("user/getProgress", this.selectedAlbum);
} }

View File

@ -84,7 +84,8 @@ export default {
if (context.state._id == -1) { if (context.state._id == -1) {
return; 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) { getProgress(context, parent) {
if (context.state._id == -1) { if (context.state._id == -1) {
@ -97,6 +98,13 @@ export default {
parent.progress = res.data; 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) { savePlayerSettings(context) {
let body = { let body = {
repeat: context.rootGetters["player/repeatType"], repeat: context.rootGetters["player/repeatType"],