diff --git a/resources/assets/js/app.vue b/resources/assets/js/app.vue index e2173646..aa387394 100644 --- a/resources/assets/js/app.vue +++ b/resources/assets/js/app.vue @@ -167,10 +167,11 @@ /** * Load (display) a main panel (view). * - * @param string view The view, which can be found under components/main-wrapper/main-content. + * @param string view The view, which can be found under components/main-wrapper/main-content. + * @param [...args] Extra data to attach to the view. */ - loadMainView(view) { - this.$broadcast('main-content-view:load', view); + loadMainView(view, ...args) { + this.$broadcast('main-content-view:load', view, ...args); }, /** @@ -179,15 +180,13 @@ * @param {Object} playlist The playlist object */ loadPlaylist(playlist) { - this.$broadcast('playlist:load', playlist); - this.loadMainView('playlist'); + this.loadMainView('playlist', playlist); }, /** * Load the Favorites view. */ loadFavorites() { - this.$broadcast('favorites:load'); this.loadMainView('favorites'); }, @@ -197,8 +196,7 @@ * @param {Object} album The album object */ loadAlbum(album) { - this.$broadcast('album:load', album); - this.loadMainView('album'); + this.loadMainView('album', album); }, /** @@ -207,8 +205,7 @@ * @param {Object} artist The artist object */ loadArtist(artist) { - this.$broadcast('artist:load', artist); - this.loadMainView('artist'); + this.loadMainView('artist', artist); }, /** diff --git a/resources/assets/js/components/main-wrapper/main-content/album.vue b/resources/assets/js/components/main-wrapper/main-content/album.vue index 6af0770d..54f9e6e9 100644 --- a/resources/assets/js/components/main-wrapper/main-content/album.vue +++ b/resources/assets/js/components/main-wrapper/main-content/album.vue @@ -69,13 +69,16 @@ events: { /** - * Listen to 'album:load' event (triggered from $root currently) - * to load the requested album into view. - * - * @param {Object} album + * Listen to 'main-content-view:load' event (triggered from $root currently) + * to load the requested album into view if applicable. + * + * @param {string} view The view name + * @param {Object} album The album object */ - 'album:load': function (album) { - this.album = album; + 'main-content-view:load': function (view, album) { + if (view === 'album') { + this.album = album; + } }, }, diff --git a/resources/assets/js/components/main-wrapper/main-content/artist.vue b/resources/assets/js/components/main-wrapper/main-content/artist.vue index 153ebc3b..1afa80b4 100644 --- a/resources/assets/js/components/main-wrapper/main-content/artist.vue +++ b/resources/assets/js/components/main-wrapper/main-content/artist.vue @@ -69,14 +69,17 @@ events: { /** - * Listen to 'artist:load' event (triggered from $root currently) - * to load the requested artist into view. - * - * @param {Object} artist + * Listen to 'main-content-view:load' event (triggered from $root currently) + * to load the requested artist into view if applicable. + * + * @param {string} view The view's name + * @param {Object} artist */ - 'artist:load': function (artist) { - artistStore.getSongsByArtist(artist); - this.artist = artist; + 'main-content-view:load': function (view, artist) { + if (view === 'artist') { + artistStore.getSongsByArtist(artist); + this.artist = artist; + } }, }, diff --git a/resources/assets/js/components/main-wrapper/main-content/playlist.vue b/resources/assets/js/components/main-wrapper/main-content/playlist.vue index ce427f38..b788f835 100644 --- a/resources/assets/js/components/main-wrapper/main-content/playlist.vue +++ b/resources/assets/js/components/main-wrapper/main-content/playlist.vue @@ -76,13 +76,16 @@ events: { /** - * Listen to 'playlist:load' event (triggered from $root currently) - * to load the requested playlist into view. - * - * @param {Object} playlist + * Listen to 'main-content-view:load' event (triggered from $root currently) + * to load the requested playlist into view if applicable. + * + * @param {string} view The view's name. + * @param {Object} playlist */ - 'playlist:load': function (playlist) { - this.playlist = playlist; + 'main-content-view:load': function (view, playlist) { + if (view === 'playlist') { + this.playlist = playlist; + } }, }, diff --git a/resources/assets/js/components/main-wrapper/sidebar/playlist-item.vue b/resources/assets/js/components/main-wrapper/sidebar/playlist-item.vue index 3dd19f00..a20070ba 100644 --- a/resources/assets/js/components/main-wrapper/sidebar/playlist-item.vue +++ b/resources/assets/js/components/main-wrapper/sidebar/playlist-item.vue @@ -151,24 +151,12 @@ }, events: { - /** - * Listen to 'playlist:load' event to determine if the current item should be highlighted. - * - * @param {Object} playlist The playlist being loaded. - */ - 'playlist:load': function (playlist) { - this.active = this.playlist === playlist; - }, - - /** - * Listen to 'favorites:load' event to highlight the Favorites item if need be. - */ - 'favorites:load': function () { - this.active = this.isFavorites; - }, - - 'main-content-view:load': function (view) { - if (view !== 'playlist' && view !== 'favorites') { + 'main-content-view:load': function (view, playlist) { + if (view === 'favorites') { + this.active = this.isFavorites; + } else if (view === 'playlist') { + this.active = this.playlist === playlist; + } else { this.active = false; } },