From 15a739b6a058890d5d6085a11b30b6657b6254aa Mon Sep 17 00:00:00 2001 From: Jason Henriquez Date: Sat, 25 Nov 2023 01:40:45 -0600 Subject: [PATCH] Move timestamps to utils store --- .../subscriptions-community.js | 4 +- .../subscriptions-live/subscriptions-live.js | 4 +- .../subscriptions-shorts.js | 4 +- .../subscriptions-videos.js | 4 +- src/renderer/store/modules/settings.js | 6 -- src/renderer/store/modules/utils.js | 56 ++++++++++++++++++- src/renderer/views/Popular/Popular.js | 8 +-- src/renderer/views/Trending/Trending.js | 9 ++- 8 files changed, 73 insertions(+), 22 deletions(-) diff --git a/src/renderer/components/subscriptions-community/subscriptions-community.js b/src/renderer/components/subscriptions-community/subscriptions-community.js index 3696644cb..3b1ba5bb3 100644 --- a/src/renderer/components/subscriptions-community/subscriptions-community.js +++ b/src/renderer/components/subscriptions-community/subscriptions-community.js @@ -145,7 +145,7 @@ export default defineComponent({ return posts }))).flatMap((o) => o) postList.push(...postListFromRemote) - this.updateLastCommunityRefreshTimestamp(new Date()) + this.setLastCommunityRefreshTimestamp(new Date()) postList.sort((a, b) => { return calculatePublishedDate(b.publishedText) - calculatePublishedDate(a.publishedText) }) @@ -216,12 +216,12 @@ export default defineComponent({ }, ...mapActions([ - 'updateLastCommunityRefreshTimestamp', 'updateShowProgressBar', 'updateSubscriptionPostsCacheByChannel', ]), ...mapMutations([ + 'setLastCommunityRefreshTimestamp', 'setProgressBarPercentage' ]) } diff --git a/src/renderer/components/subscriptions-live/subscriptions-live.js b/src/renderer/components/subscriptions-live/subscriptions-live.js index 062a13389..b203dbd9f 100644 --- a/src/renderer/components/subscriptions-live/subscriptions-live.js +++ b/src/renderer/components/subscriptions-live/subscriptions-live.js @@ -159,7 +159,7 @@ export default defineComponent({ return videos }))).flatMap((o) => o) videoList.push(...videoListFromRemote) - this.updateLastLiveRefreshTimestamp(new Date()) + this.setLastLiveRefreshTimestamp(new Date()) this.videoList = updateVideoListAfterProcessing(videoList) this.isLoading = false @@ -340,12 +340,12 @@ export default defineComponent({ }, ...mapActions([ - 'updateLastLiveRefreshTimestamp', 'updateShowProgressBar', 'updateSubscriptionLiveCacheByChannel', ]), ...mapMutations([ + 'setLastLiveRefreshTimestamp', 'setProgressBarPercentage' ]) } diff --git a/src/renderer/components/subscriptions-shorts/subscriptions-shorts.js b/src/renderer/components/subscriptions-shorts/subscriptions-shorts.js index d4fa214a8..fd58bb3a5 100644 --- a/src/renderer/components/subscriptions-shorts/subscriptions-shorts.js +++ b/src/renderer/components/subscriptions-shorts/subscriptions-shorts.js @@ -136,7 +136,7 @@ export default defineComponent({ return videos }))).flatMap((o) => o) videoList.push(...videoListFromRemote) - this.updateLastShortRefreshTimestamp(new Date()) + this.setLastShortRefreshTimestamp(new Date()) this.videoList = updateVideoListAfterProcessing(videoList) this.isLoading = false @@ -230,12 +230,12 @@ export default defineComponent({ }, ...mapActions([ - 'updateLastShortRefreshTimestamp', 'updateShowProgressBar', 'updateSubscriptionShortsCacheByChannel', ]), ...mapMutations([ + 'setLastShortRefreshTimestamp', 'setProgressBarPercentage' ]) } diff --git a/src/renderer/components/subscriptions-videos/subscriptions-videos.js b/src/renderer/components/subscriptions-videos/subscriptions-videos.js index 3202cc318..54772ec99 100644 --- a/src/renderer/components/subscriptions-videos/subscriptions-videos.js +++ b/src/renderer/components/subscriptions-videos/subscriptions-videos.js @@ -163,7 +163,7 @@ export default defineComponent({ return videos }))).flatMap((o) => o) videoList.push(...videoListFromRemote) - this.updateLastVideoRefreshTimestamp(new Date()) + this.setLastVideoRefreshTimestamp(new Date()) this.videoList = updateVideoListAfterProcessing(videoList) this.isLoading = false @@ -342,12 +342,12 @@ export default defineComponent({ }, ...mapActions([ - 'updateLastVideoRefreshTimestamp', 'updateShowProgressBar', 'updateSubscriptionVideosCacheByChannel', ]), ...mapMutations([ + 'setLastVideoRefreshTimestamp', 'setProgressBarPercentage' ]) } diff --git a/src/renderer/store/modules/settings.js b/src/renderer/store/modules/settings.js index b6711ffdd..ba2ff912b 100644 --- a/src/renderer/store/modules/settings.js +++ b/src/renderer/store/modules/settings.js @@ -227,12 +227,6 @@ const state = { hideChapters: false, showDistractionFreeTitles: false, landingPage: 'subscriptions', - lastVideoRefreshTimestamp: '', - lastShortRefreshTimestamp: '', - lastLiveRefreshTimestamp: '', - lastCommunityRefreshTimestamp: '', - lastPopularRefreshTimestamp: '', - lastTrendingRefreshTimestamp: '', listType: 'grid', maxVideoPlaybackRate: 3, playNextVideo: false, diff --git a/src/renderer/store/modules/utils.js b/src/renderer/store/modules/utils.js index 4ec7a5df6..12c29b865 100644 --- a/src/renderer/store/modules/utils.js +++ b/src/renderer/store/modules/utils.js @@ -44,7 +44,13 @@ const state = { externalPlayerNames: [], externalPlayerNameTranslationKeys: [], externalPlayerValues: [], - externalPlayerCmdArguments: {} + externalPlayerCmdArguments: {}, + lastVideoRefreshTimestamp: '', + lastShortRefreshTimestamp: '', + lastLiveRefreshTimestamp: '', + lastCommunityRefreshTimestamp: '', + lastPopularRefreshTimestamp: '', + lastTrendingRefreshTimestamp: '', } const getters = { @@ -118,6 +124,30 @@ const getters = { getExternalPlayerCmdArguments () { return state.externalPlayerCmdArguments + }, + + getLastTrendingRefreshTimestamp () { + return state.lastTrendingRefreshTimestamp + }, + + getLastPopularRefreshTimestamp () { + return state.lastPopularRefreshTimestamp + }, + + getLastCommunityRefreshTimestamp () { + return state.lastCommunityRefreshTimestamp + }, + + getLastShortRefreshTimestamp () { + return state.lastShortRefreshTimestamp + }, + + getLastLiveRefreshTimestamp () { + return state.lastLiveRefreshTimestamp + }, + + getLastVideoRefreshTimestamp () { + return state.lastVideoRefreshTimestamp } } @@ -703,6 +733,30 @@ const mutations = { state.trendingCache[page] = value }, + setLastTrendingRefreshTimestamp (state, value) { + state.lastTrendingRefreshTimestamp = value + }, + + setLastPopularRefreshTimestamp (state, value) { + state.lastPopularRefreshTimestamp = value + }, + + setLastCommunityRefreshTimestamp (state, value) { + state.lastCommunityRefreshTimestamp = value + }, + + setLastShortRefreshTimestamp (state, value) { + state.lastShortRefreshTimestamp = value + }, + + setLastLiveRefreshTimestamp (state, value) { + state.lastLiveRefreshTimestamp = value + }, + + setLastVideoRefreshTimestamp (state, value) { + state.lastVideoRefreshTimestamp = value + }, + clearTrendingCache(state) { state.trendingCache = { default: null, diff --git a/src/renderer/views/Popular/Popular.js b/src/renderer/views/Popular/Popular.js index 63646b06f..0622217a9 100644 --- a/src/renderer/views/Popular/Popular.js +++ b/src/renderer/views/Popular/Popular.js @@ -1,5 +1,5 @@ import { defineComponent } from 'vue' -import { mapActions } from 'vuex' +import { mapMutations } from 'vuex' import FtLoader from '../../components/ft-loader/ft-loader.vue' import FtCard from '../../components/ft-card/ft-card.vue' import FtElementList from '../../components/ft-element-list/ft-element-list.vue' @@ -69,7 +69,7 @@ export default defineComponent({ this.shownResults = result.filter((item) => { return item.type === 'video' || item.type === 'shortVideo' || item.type === 'channel' || item.type === 'playlist' }) - this.updateLastPopularRefreshTimestamp(new Date()) + this.setLastPopularRefreshTimestamp(new Date()) this.isLoading = false this.$store.commit('setPopularCache', this.shownResults) }, @@ -96,8 +96,8 @@ export default defineComponent({ } }, - ...mapActions([ - 'updateLastPopularRefreshTimestamp' + ...mapMutations([ + 'setLastPopularRefreshTimestamp' ]) } }) diff --git a/src/renderer/views/Trending/Trending.js b/src/renderer/views/Trending/Trending.js index 4645c3a7b..9d46699cd 100644 --- a/src/renderer/views/Trending/Trending.js +++ b/src/renderer/views/Trending/Trending.js @@ -1,5 +1,5 @@ import { defineComponent } from 'vue' -import { mapActions } from 'vuex' +import { mapActions, mapMutations } from 'vuex' import FtCard from '../../components/ft-card/ft-card.vue' import FtLoader from '../../components/ft-loader/ft-loader.vue' import FtElementList from '../../components/ft-element-list/ft-element-list.vue' @@ -96,7 +96,7 @@ export default defineComponent({ this.getTrendingInfoLocal() } - this.updateLastTrendingRefreshTimestamp(new Date()) + this.setLastTrendingRefreshTimestamp(new Date()) }, getTrendingInfoLocal: async function () { @@ -198,8 +198,11 @@ export default defineComponent({ }, ...mapActions([ - 'updateLastTrendingRefreshTimestamp', 'showOutlines' + ]), + + ...mapMutations([ + 'setLastTrendingRefreshTimestamp' ]) } })