diff --git a/src/components/tops/Topbar.vue b/src/components/tops/Topbar.vue index fa2f7adf9f..e2719787df 100644 --- a/src/components/tops/Topbar.vue +++ b/src/components/tops/Topbar.vue @@ -619,6 +619,8 @@ export default { configureProduction(routeProductionId, routeEpisodeId = undefined) { this.setProduction(routeProductionId) this.currentProductionId = routeProductionId + this.currentEpisodeId = null + this.clearEpisodes() if (this.isTVShow) { this.loadEpisodes() .then(episodes => { @@ -644,7 +646,6 @@ export default { }) .catch(console.error) } else { - this.clearEpisodes() this.updateCombosFromRoute() } }, @@ -764,52 +765,6 @@ export default { route.name = this.isCurrentUserClient ? 'playlists' : 'assets' } return route - }, - - resetEpisodeForTVShow(soft = false) { - // TODO seems deprecated - const section = - this.currentProjectSection || this.getCurrentSectionFromRoute() - const isEditSection = this.editSections.includes(section) - const isShotSection = this.shotSections.includes(section) - const isAssetEpisode = ['all', 'main'].includes(this.currentEpisodeId) - const production = this.productionMap.get(this.currentProductionId) - if (!production) return - const isTVShow = production.production_type === 'tvshow' - - if (isAssetEpisode) { - // It's an asset episode. We have to switch if we are in a shot - // section. - if (isShotSection) { - // Set current episode to first episode if it's a shot section. - this.currentEpisodeId = - this.episodes.length > 0 ? this.episodes[0].id : null - } - } - - // If no episode is set and we are in a tv show, select the first one. - if (isTVShow) { - // It's an asset section, and episode is not set, we chose all - if (isEditSection && !this.currentEpisodeId) { - this.currentEpisodeId = 'all' - this.setCurrentEpisode(this.currentEpisodeId) - // It's a shot section, and episode is not set, we chose the first - // one. - } else if (!this.currentEpisode) { - if (!this.currentEpisodeId) { - if (this.episodes.length > 0) { - this.currentEpisodeId = this.episodes[0].id - } else { - this.currentEpisodeId = production.first_episode_id - } - } - this.setCurrentEpisode(this.currentEpisodeId) - } else if (!this.currentEpisodeId && this.currentEpisode) { - this.currentEpisodeId = this.currentEpisode.id - } - } else { - this.currentEpisodeId = null - } } }, diff --git a/src/store/modules/episodes.js b/src/store/modules/episodes.js index e81352138a..c4974e0f46 100644 --- a/src/store/modules/episodes.js +++ b/src/store/modules/episodes.js @@ -565,11 +565,9 @@ const mutations = { }, [SET_CURRENT_EPISODE](state, episodeId) { - if (episodeId) { - if (episodeId === 'main') { - state.currentEpisode = { id: 'main' } - } else if (episodeId === 'all') { - state.currentEpisode = { id: 'all' } + if (episodeId && episodeId !== state.currentEpisode?.id) { + if (['all', 'main'].includes(episodeId)) { + state.currentEpisode = { id: episodeId } } else { state.currentEpisode = cache.episodeMap.get(episodeId) }