Prechádzať zdrojové kódy

fix(SortablePlaylists): playlists wouldn't update after dragging it to a new position

Kristian Vos 3 rokov pred
rodič
commit
a398d55483

+ 9 - 2
frontend/src/mixins/SortablePlaylists.vue

@@ -12,10 +12,17 @@ export default {
 		};
 	},
 	computed: {
+		playlists: {
+			get() {
+				return this.$store.state.user.playlists.playlists;
+			},
+			set(playlists) {
+				this.$store.commit("user/playlists/updatePlaylists", playlists);
+			}
+		},
 		...mapState({
 			station: state => state.station.station,
-			myUserId: state => state.user.auth.userId,
-			playlists: state => state.user.playlists.playlists
+			myUserId: state => state.user.auth.userId
 		}),
 		dragOptions() {
 			return {

+ 5 - 0
frontend/src/store/modules/user.js

@@ -210,6 +210,8 @@ const modules = {
 			editPlaylist: ({ commit }, id) => commit("editPlaylist", id),
 			setPlaylists: ({ commit }, playlists) =>
 				commit("setPlaylists", playlists),
+			updatePlaylists: ({ commit }, playlists) =>
+				commit("updatePlaylists", playlists),
 			addPlaylist: ({ commit }, playlist) =>
 				commit("addPlaylist", playlist),
 			removePlaylist: ({ commit }, playlistId) =>
@@ -223,6 +225,9 @@ const modules = {
 				state.fetchedPlaylists = true;
 				state.playlists = playlists;
 			},
+			updatePlaylists(state, playlists) {
+				state.playlists = playlists;
+			},
 			addPlaylist(state, playlist) {
 				state.playlists.push(playlist);
 			},