Move timestamps to utils store

This commit is contained in:
Jason Henriquez 2023-11-25 01:40:45 -06:00
parent e12bea9af3
commit 15a739b6a0
8 changed files with 73 additions and 22 deletions

View File

@ -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'
])
}

View File

@ -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'
])
}

View File

@ -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'
])
}

View File

@ -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'
])
}

View File

@ -227,12 +227,6 @@ const state = {
hideChapters: false,
showDistractionFreeTitles: false,
landingPage: 'subscriptions',
lastVideoRefreshTimestamp: '',
lastShortRefreshTimestamp: '',
lastLiveRefreshTimestamp: '',
lastCommunityRefreshTimestamp: '',
lastPopularRefreshTimestamp: '',
lastTrendingRefreshTimestamp: '',
listType: 'grid',
maxVideoPlaybackRate: 3,
playNextVideo: false,

View File

@ -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,

View File

@ -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'
])
}
})

View File

@ -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'
])
}
})