Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/renderer/components/SubscriptionsLive.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ const fetchSubscriptionsAutomatically = computed(() => store.getters.getFetchSub

const activeSubscriptionList = computed(() => store.getters.getActiveProfile.subscriptions)

const activeProfileId = computed(() => store.getters.getActiveProfile._id)

const cacheEntriesForAllActiveProfileChannels = computed(() => {
const liveCache = store.getters.getLiveCache
const entries = []
Expand Down Expand Up @@ -140,22 +142,25 @@ function loadVideosFromRemoteFirstPerWindowSometimes() {

alreadyLoadedRemotely = true
loadVideosForSubscriptionsFromRemote()
store.commit('setSubscriptionForLiveStreamsFirstAutoFetchRun')
store.commit('setSubscriptionForLiveStreamsFirstAutoFetchRun', activeProfileId.value)
}

function loadVideosFromCacheSometimes() {
// Can only load reliably when cache ready
if (!subscriptionCacheReady.value) { return }

// This method is called on view visible
if (videoCacheForAllActiveProfileChannelsPresent.value) {
loadVideosFromCacheForAllActiveProfileChannels()
// Check if this profile needs to be auto-fetched for the first time
if (fetchSubscriptionsAutomatically.value && !store.getters.getSubscriptionForLiveStreamsFirstAutoFetchRun) {
// `isLoading.value = false` is called inside `loadVideosForSubscriptionsFromRemote` when needed
alreadyLoadedRemotely = true
loadVideosForSubscriptionsFromRemote()
store.commit('setSubscriptionForLiveStreamsFirstAutoFetchRun', activeProfileId.value)
return
}

if (fetchSubscriptionsAutomatically.value) {
// `isLoading.value = false` is called inside `loadVideosForSubscriptionsFromRemote` when needed
loadVideosForSubscriptionsFromRemote()
// This method is called on view visible
if (videoCacheForAllActiveProfileChannelsPresent.value) {
loadVideosFromCacheForAllActiveProfileChannels()
return
}

Expand Down
19 changes: 12 additions & 7 deletions src/renderer/components/SubscriptionsPosts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const fetchSubscriptionsAutomatically = computed(() => store.getters.getFetchSub

const activeSubscriptionList = computed(() => store.getters.getActiveProfile.subscriptions)

const activeProfileId = computed(() => store.getters.getActiveProfile._id)

const cacheEntriesForAllActiveProfileChannels = computed(() => {
const postsCache = store.getters.getPostsCache
const entries = []
Expand Down Expand Up @@ -130,22 +132,25 @@ function loadPostsFromRemoteFirstPerWindowSometimes() {

alreadyLoadedRemotely = true
loadPostsForSubscriptionsFromRemote()
store.commit('setSubscriptionForPostsFirstAutoFetchRun')
store.commit('setSubscriptionForPostsFirstAutoFetchRun', activeProfileId.value)
}

function loadPostsFromCacheSometimes() {
// Can only load reliably when cache ready
if (!subscriptionCacheReady.value) { return }

// This method is called on view visible
if (postCacheForAllActiveProfileChannelsPresent.value) {
loadPostsFromCacheForAllActiveProfileChannels()
// Check if this profile needs to be auto-fetched for the first time
if (fetchSubscriptionsAutomatically.value && !store.getters.getSubscriptionForPostsFirstAutoFetchRun) {
// `isLoading.value = false` is called inside `loadPostsForSubscriptionsFromRemote` when needed
alreadyLoadedRemotely = true
loadPostsForSubscriptionsFromRemote()
store.commit('setSubscriptionForPostsFirstAutoFetchRun', activeProfileId.value)
return
}

if (fetchSubscriptionsAutomatically.value) {
// `isLoading.value = false` is called inside `loadPostsForSubscriptionsFromRemote` when needed
loadPostsForSubscriptionsFromRemote()
// This method is called on view visible
if (postCacheForAllActiveProfileChannelsPresent.value) {
loadPostsFromCacheForAllActiveProfileChannels()
return
}

Expand Down
19 changes: 12 additions & 7 deletions src/renderer/components/SubscriptionsShorts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ const fetchSubscriptionsAutomatically = computed(() => store.getters.getFetchSub

const activeSubscriptionList = computed(() => store.getters.getActiveProfile.subscriptions)

const activeProfileId = computed(() => store.getters.getActiveProfile._id)

const cacheEntriesForAllActiveProfileChannels = computed(() => {
const shortsCache = store.getters.getShortsCache
const entries = []
Expand Down Expand Up @@ -135,22 +137,25 @@ function loadVideosFromRemoteFirstPerWindowSometimes() {

alreadyLoadedRemotely = true
loadVideosForSubscriptionsFromRemote()
store.commit('setSubscriptionForShortsFirstAutoFetchRun')
store.commit('setSubscriptionForShortsFirstAutoFetchRun', activeProfileId.value)
}

function loadVideosFromCacheSometimes() {
// Can only load reliably when cache ready
if (!subscriptionCacheReady.value) { return }

// This method is called on view visible
if (videoCacheForAllActiveProfileChannelsPresent.value) {
loadVideosFromCacheForAllActiveProfileChannels()
// Check if this profile needs to be auto-fetched for the first time
if (fetchSubscriptionsAutomatically.value && !store.getters.getSubscriptionForShortsFirstAutoFetchRun) {
// `isLoading.value = false` is called inside `loadVideosForSubscriptionsFromRemote` when needed
alreadyLoadedRemotely = true
loadVideosForSubscriptionsFromRemote()
store.commit('setSubscriptionForShortsFirstAutoFetchRun', activeProfileId.value)
return
}

if (fetchSubscriptionsAutomatically.value) {
// `isLoading.value = false` is called inside `loadVideosForSubscriptionsFromRemote` when needed
loadVideosForSubscriptionsFromRemote()
// This method is called on view visible
if (videoCacheForAllActiveProfileChannelsPresent.value) {
loadVideosFromCacheForAllActiveProfileChannels()
return
}

Expand Down
19 changes: 12 additions & 7 deletions src/renderer/components/SubscriptionsVideos.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ const fetchSubscriptionsAutomatically = computed(() => store.getters.getFetchSub

const activeSubscriptionList = computed(() => store.getters.getActiveProfile.subscriptions)

const activeProfileId = computed(() => store.getters.getActiveProfile._id)

const cacheEntriesForAllActiveProfileChannels = computed(() => {
const videoCache = store.getters.getVideoCache
const entries = []
Expand Down Expand Up @@ -139,22 +141,25 @@ function loadVideosFromRemoteFirstPerWindowSometimes() {

alreadyLoadedRemotely = true
loadVideosForSubscriptionsFromRemote()
store.commit('setSubscriptionForVideosFirstAutoFetchRun')
store.commit('setSubscriptionForVideosFirstAutoFetchRun', activeProfileId.value)
}

function loadVideosFromCacheSometimes() {
// Can only load reliably when cache ready
if (!subscriptionCacheReady.value) { return }

// This method is called on view visible
if (videoCacheForAllActiveProfileChannelsPresent.value) {
loadVideosFromCacheForAllActiveProfileChannels()
// Check if this profile needs to be auto-fetched for the first time
if (fetchSubscriptionsAutomatically.value && !store.getters.getSubscriptionForVideosFirstAutoFetchRun) {
// `isLoading.value = false` is called inside `loadVideosForSubscriptionsFromRemote` when needed
alreadyLoadedRemotely = true
loadVideosForSubscriptionsFromRemote()
store.commit('setSubscriptionForVideosFirstAutoFetchRun', activeProfileId.value)
return
}

if (fetchSubscriptionsAutomatically.value) {
// `isLoading.value = false` is called inside `loadVideosForSubscriptionsFromRemote` when needed
loadVideosForSubscriptionsFromRemote()
// This method is called on view visible
if (videoCacheForAllActiveProfileChannelsPresent.value) {
loadVideosFromCacheForAllActiveProfileChannels()
return
}

Expand Down
44 changes: 24 additions & 20 deletions src/renderer/store/modules/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ const state = {
podcasts: ''
},
subscriptionFirstAutoFetchRunData: {
videos: false,
liveStreams: false,
shorts: false,
posts: false,
videos: new Set(),
liveStreams: new Set(),
shorts: new Set(),
posts: new Set(),
},
appTitle: '',
openPrompts: new Set()
Expand Down Expand Up @@ -159,17 +159,21 @@ const getters = {
return state.lastPopularRefreshTimestamp
},

getSubscriptionForVideosFirstAutoFetchRun(state) {
return state.subscriptionFirstAutoFetchRunData.videos === true
getSubscriptionForVideosFirstAutoFetchRun: (state, getters, rootState, rootGetters) => {
const activeProfileId = rootGetters.getActiveProfile._id
return state.subscriptionFirstAutoFetchRunData.videos.has(activeProfileId)
},
getSubscriptionForLiveStreamsFirstAutoFetchRun (state) {
return state.subscriptionFirstAutoFetchRunData.liveStreams === true
getSubscriptionForLiveStreamsFirstAutoFetchRun: (state, getters, rootState, rootGetters) => {
const activeProfileId = rootGetters.getActiveProfile._id
return state.subscriptionFirstAutoFetchRunData.liveStreams.has(activeProfileId)
},
getSubscriptionForShortsFirstAutoFetchRun (state) {
return state.subscriptionFirstAutoFetchRunData.shorts === true
getSubscriptionForShortsFirstAutoFetchRun: (state, getters, rootState, rootGetters) => {
const activeProfileId = rootGetters.getActiveProfile._id
return state.subscriptionFirstAutoFetchRunData.shorts.has(activeProfileId)
},
getSubscriptionForPostsFirstAutoFetchRun (state) {
return state.subscriptionFirstAutoFetchRunData.posts === true
getSubscriptionForPostsFirstAutoFetchRun: (state, getters, rootState, rootGetters) => {
const activeProfileId = rootGetters.getActiveProfile._id
return state.subscriptionFirstAutoFetchRunData.posts.has(activeProfileId)
},
getAppTitle (state) {
return state.appTitle
Expand Down Expand Up @@ -787,17 +791,17 @@ const mutations = {
state.openPrompts.delete(id)
},

setSubscriptionForVideosFirstAutoFetchRun (state) {
state.subscriptionFirstAutoFetchRunData.videos = true
setSubscriptionForVideosFirstAutoFetchRun (state, profileId) {
state.subscriptionFirstAutoFetchRunData.videos.add(profileId)
},
setSubscriptionForLiveStreamsFirstAutoFetchRun (state) {
state.subscriptionFirstAutoFetchRunData.liveStreams = true
setSubscriptionForLiveStreamsFirstAutoFetchRun (state, profileId) {
state.subscriptionFirstAutoFetchRunData.liveStreams.add(profileId)
},
setSubscriptionForShortsFirstAutoFetchRun (state) {
state.subscriptionFirstAutoFetchRunData.shorts = true
setSubscriptionForShortsFirstAutoFetchRun (state, profileId) {
state.subscriptionFirstAutoFetchRunData.shorts.add(profileId)
},
setSubscriptionForPostsFirstAutoFetchRun (state) {
state.subscriptionFirstAutoFetchRunData.posts = true
setSubscriptionForPostsFirstAutoFetchRun (state, profileId) {
state.subscriptionFirstAutoFetchRunData.posts.add(profileId)
}
}

Expand Down