-
-
+
+
+
-
-
diff --git a/src/components/PlaylistCreateModal/index.vue b/src/components/PlaylistCreateModal/index.vue
index c0b7ca0..91ed383 100644
--- a/src/components/PlaylistCreateModal/index.vue
+++ b/src/components/PlaylistCreateModal/index.vue
@@ -54,7 +54,7 @@
methods: {
...mapActions({
- addNotification: 'notification/addNotification',
+ addNotification: 'notification/add',
getUserPlaylists: 'user/getCurrentUserPlaylists',
clearUserPlaylists: 'user/clearUserPlaylists',
}),
diff --git a/src/components/PlaylistUpdateModal/index.vue b/src/components/PlaylistUpdateModal/index.vue
index 566c533..c3a72ca 100644
--- a/src/components/PlaylistUpdateModal/index.vue
+++ b/src/components/PlaylistUpdateModal/index.vue
@@ -64,7 +64,7 @@
methods: {
...mapActions({
- addNotification: 'notification/addNotification',
+ addNotification: 'notification/add',
getUserPlaylists: 'user/getCurrentUserPlaylists',
clearUserPlaylists: 'user/clearUserPlaylists',
fetchPlaylist: 'playlist/fetchPlaylist',
@@ -101,6 +101,16 @@
return false;
}
+ if (!this.description) {
+ this.addNotification({
+ type: 'error',
+ message: 'You must give your playlist a description.',
+ duration: 3000
+ });
+
+ return false;
+ }
+
return valid;
},
@@ -127,7 +137,6 @@
await api.spotify.playlists.updatePlaylist(this.user.id, playlistID, this.name, this.description);
this.fetchPlaylist({userID: this.userID, playlistID});
-
this.clearUserPlaylists();
this.getUserPlaylists();
@@ -138,7 +147,7 @@
});
} catch (e) {
- console.log(e);
+ console.error(e);
}
this.hide();
diff --git a/src/store/modules/notification.js b/src/store/modules/notification.js
index 28e7cfb..72947e2 100644
--- a/src/store/modules/notification.js
+++ b/src/store/modules/notification.js
@@ -1,9 +1,9 @@
const state = {
- notifications: []
+ notifications: [],
};
const getters = {
- getNotifications: state => state.notifications
+ getNotifications: state => state.notifications,
};
const mutations = {
@@ -17,12 +17,19 @@ const mutations = {
};
const actions = {
- addNotification({commit}, notification) {
+ add({ commit, dispatch }, notification) {
commit('NOTIFICATION_ADD', notification);
+
+ if (notification.duration > 0) {
+ setTimeout(() => {
+ dispatch('remove', notification);
+ }, notification.duration);
+ }
},
- removeNotification({commit}, notification) {
+
+ remove({ commit }, notification) {
commit('NOTIFICATION_REMOVE', notification);
- }
+ },
};
const module = {
@@ -30,7 +37,7 @@ const module = {
state,
getters,
mutations,
- actions
+ actions,
};
export default module;