Explorar o código

feat(playlists): when playlist created, edit modal opens

Signed-off-by: Jonathan <theflametrooper@gmail.com>
Jonathan %!s(int64=5) %!d(string=hai) anos
pai
achega
b28f020329

+ 3 - 1
backend/logic/actions/playlists.js

@@ -163,7 +163,9 @@ let lib = {
 			}
 			cache.pub('playlist.create', playlist._id);
 			logger.success("PLAYLIST_CREATE", `Successfully created private playlist for user "${userId}".`);
-			cb({ 'status': 'success', 'message': 'Successfully created playlist' });
+			cb({ status: 'success', message: 'Successfully created playlist', data: {
+				_id: playlist._id
+			} });
 		});
 	}),
 

+ 17 - 3
frontend/components/Modals/Playlists/Create.vue

@@ -21,6 +21,8 @@
 </template>
 
 <script>
+import { mapActions } from "vuex";
+
 import { Toast } from "vue-roaster";
 import Modal from "../Modal.vue";
 import io from "../../../io";
@@ -60,10 +62,22 @@ export default {
 
 			this.socket.emit("playlists.create", this.playlist, res => {
 				Toast.methods.addToast(res.message, 3000);
+
+				if (res.status === "success") {
+					this.toggleModal({
+						sector: "station",
+						modal: "createPlaylist"
+					});
+					this.editPlaylist(res.data._id);
+					this.toggleModal({
+						sector: "station",
+						modal: "editPlaylist"
+					});
+				}
 			});
-			this.$parent.modals.createPlaylist = !this.$parent.modals
-				.createPlaylist;
-		}
+		},
+		...mapActions("modals", ["toggleModal"]),
+		...mapActions("user/playlists", ["editPlaylist"])
 	}
 };
 </script>