diff --git a/src/components/EditorPlaylist.vue b/src/components/EditorPlaylist.vue
index cfcbcbf0..844cb031 100644
--- a/src/components/EditorPlaylist.vue
+++ b/src/components/EditorPlaylist.vue
@@ -1,6 +1,6 @@
-
+
diff --git a/src/store/editor/actions.js b/src/store/editor/actions.js
index 1cfee368..978ab7a2 100644
--- a/src/store/editor/actions.js
+++ b/src/store/editor/actions.js
@@ -1,5 +1,5 @@
import moment from 'moment';
-import Spotify from '../../utils/Spotify';
+import Spotify, { api } from '../../utils/Spotify';
import 'moment-duration-format';
export default {
@@ -29,6 +29,15 @@ export default {
}
},
+ async reorderTracks({ dispatch, state }, { rangeStart, insertBefore }) {
+ try {
+ await api.reorderTracksInPlaylist(state.playlist.id, rangeStart, insertBefore);
+ dispatch('fetchPlaylist', state.playlist.id);
+ } catch (err) {
+ Spotify.handleApiError(dispatch, err);
+ }
+ },
+
setError({ commit }, errorMessage) {
if (errorMessage === 'Token expired') {
commit('user/setAccessToken', null, { root: true });
diff --git a/src/utils/Spotify.js b/src/utils/Spotify.js
index 8a8d8672..f37bc1a2 100644
--- a/src/utils/Spotify.js
+++ b/src/utils/Spotify.js
@@ -1,6 +1,6 @@
import SpotifyWebApi from 'spotify-web-api-js';
-const api = new SpotifyWebApi();
+export const api = new SpotifyWebApi();
/**
* This is a collection of (mostly) functions that use the spotify-web-api.