From 51b42abf53566d5073d38246e1c3025057a1ab72 Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Tue, 23 Mar 2021 21:47:15 +0100 Subject: [PATCH] get values from rootState, process playlist with day start as seconds --- pages/player.vue | 33 +++++++++++---------------------- store/playlist.js | 6 ++++-- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/pages/player.vue b/pages/player.vue index 39c218c1..9499ae8d 100644 --- a/pages/player.vue +++ b/pages/player.vue @@ -369,20 +369,21 @@ export default { computed: { ...mapState('config', ['configID', 'configGui', 'configPlayout', 'timezone']), ...mapState('media', ['crumbs', 'folderTree']), - ...mapState('playlist', ['timeStr', 'timeLeft', 'currentClip', 'progressValue', 'currentClipIndex', 'currentClipDuration', 'currentClipIn', 'currentClipOut']), + ...mapState('playlist', [ + 'timeStr', 'timeLeft', 'currentClip', 'progressValue', 'currentClipIndex', + 'currentClipDuration', 'currentClipIn', 'currentClipOut', 'startInSec']), playlist: { get () { return this.$store.state.playlist.playlist }, set (list) { - this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist( - this.configPlayout.playlist.day_start, list)) + this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist(this.startInSec, list)) } } }, watch: { - listDate (date) { + listDate () { this.getPlaylist() setTimeout(() => { scrollTo(this) }, 5000) }, @@ -465,11 +466,7 @@ export default { }, async getPlaylist () { - await this.$store.dispatch('playlist/getPlaylist', { - dayStart: this.configPlayout.playlist.day_start, - date: this.listDate, - configPath: this.configGui[this.configID].playout_config - }) + await this.$store.dispatch('playlist/getPlaylist', { date: this.listDate }) }, showPreviewModal (src) { @@ -519,24 +516,18 @@ export default { this.playlist[index].out = sec } - this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist( - this.configPlayout.playlist.day_start, this.playlist)) + this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist(this.startInSec, this.playlist)) } }, removeItemFromPlaylist (index) { this.playlist.splice(index, 1) - this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist( - this.configPlayout.playlist.day_start, this.playlist)) + this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist(this.startInSec, this.playlist)) }, async resetPlaylist () { - await this.$store.dispatch('playlist/getPlaylist', { - dayStart: this.configPlayout.playlist.day_start, - date: this.listDate, - configPath: this.configGui[this.configID].playout_config - }) + await this.$store.dispatch('playlist/getPlaylist', { date: this.listDate }) }, loopClips () { @@ -554,13 +545,11 @@ export default { } } - this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist( - this.configPlayout.playlist.day_start, tempList)) + this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist(this.startInSec, tempList)) }, async savePlaylist (saveDate) { - this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist( - this.configPlayout.playlist.day_start, this.playlist)) + this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist(this.startInSec, this.playlist)) const saveList = this.playlist.map(({ begin, ...item }) => item) diff --git a/store/playlist.js b/store/playlist.js index ec515fc3..520d2141 100644 --- a/store/playlist.js +++ b/store/playlist.js @@ -51,8 +51,9 @@ export const mutations = { } export const actions = { - async getPlaylist ({ commit, dispatch, state, rootState }, { dayStart, date, configPath }) { + async getPlaylist ({ commit, dispatch, state, rootState }, { date }) { const timeInSec = this.$timeToSeconds(this.$dayjs().tz(rootState.config.timezone).format('HH:mm:ss')) + const configPath = rootState.config.configGui[rootState.config.configID].playout_config let dateToday = this.$dayjs().tz(this.timezone).format('YYYY-MM-DD') if (rootState.config.startInSec > timeInSec) { @@ -60,9 +61,10 @@ export const actions = { } const response = await this.$axios.get(`api/player/playlist/?date=${date}&config_path=${configPath}`) + console.log(rootState.config.configPlayout.playlist.day_start) if (response.data && response.data.program) { - commit('UPDATE_PLAYLIST', this.$processPlaylist(dayStart, response.data.program)) + commit('UPDATE_PLAYLIST', this.$processPlaylist(rootState.config.startInSec, response.data.program)) if (date === dateToday) { commit('UPDATE_TODAYS_PLAYLIST', _.cloneDeep(response.data.program))