Skip to content

Commit

Permalink
Various minor performance improvements to the subscription page (#5722)
Browse files Browse the repository at this point in the history
  • Loading branch information
absidue authored Sep 23, 2024
1 parent 74da704 commit b1861ff
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default defineComponent({
},
data: function () {
return {
isLoading: false,
isLoading: true,
postList: [],
errorChannels: [],
attemptedFetch: false,
Expand Down Expand Up @@ -101,8 +101,6 @@ export default defineComponent({
},
},
mounted: async function () {
this.isLoading = true

this.loadPostsFromCacheSometimes()
},
methods: {
Expand All @@ -120,11 +118,8 @@ export default defineComponent({
},

async loadPostsFromCacheForAllActiveProfileChannels() {
const postList = []
this.activeSubscriptionList.forEach((channel) => {
const channelCacheEntry = this.$store.getters.getPostsCacheByChannel(channel.id)

postList.push(...channelCacheEntry.posts)
const postList = this.cacheEntriesForAllActiveProfileChannels.flatMap((cacheEntry) => {
return cacheEntry.posts
})

postList.sort((a, b) => {
Expand All @@ -143,7 +138,6 @@ export default defineComponent({
}

const channelsToLoadFromRemote = this.activeSubscriptionList
const postList = []
let channelCount = 0
this.isLoading = true

Expand Down Expand Up @@ -193,13 +187,13 @@ export default defineComponent({
}

return posts
}))).flatMap((o) => o)
postList.push(...postListFromRemote)
postList.sort((a, b) => {
}))).flat()

postListFromRemote.sort((a, b) => {
return b.publishedTime - a.publishedTime
})

this.postList = postList
this.postList = postListFromRemote
this.isLoading = false
this.updateShowProgressBar(false)
this.lastRemoteRefreshSuccessTimestamp = new Date()
Expand Down
18 changes: 6 additions & 12 deletions src/renderer/components/subscriptions-live/subscriptions-live.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default defineComponent({
},
data: function () {
return {
isLoading: false,
isLoading: true,
videoList: [],
errorChannels: [],
attemptedFetch: false,
Expand Down Expand Up @@ -111,8 +111,6 @@ export default defineComponent({
},
},
mounted: async function () {
this.isLoading = true

this.loadVideosFromCacheSometimes()
},
methods: {
Expand All @@ -130,12 +128,10 @@ export default defineComponent({
},

async loadVideosFromCacheForAllActiveProfileChannels() {
const videoList = []
this.activeSubscriptionList.forEach((channel) => {
const channelCacheEntry = this.$store.getters.getLiveCacheByChannel(channel.id)

videoList.push(...channelCacheEntry.videos)
const videoList = this.cacheEntriesForAllActiveProfileChannels.flatMap((cacheEntry) => {
return cacheEntry.videos
})

this.videoList = updateVideoListAfterProcessing(videoList)
this.isLoading = false
},
Expand All @@ -148,7 +144,6 @@ export default defineComponent({
}

const channelsToLoadFromRemote = this.activeSubscriptionList
const videoList = []
let channelCount = 0
this.isLoading = true

Expand Down Expand Up @@ -202,10 +197,9 @@ export default defineComponent({
}

return videos
}))).flatMap((o) => o)
videoList.push(...videoListFromRemote)
}))).flat()

this.videoList = updateVideoListAfterProcessing(videoList)
this.videoList = updateVideoListAfterProcessing(videoListFromRemote)
this.isLoading = false
this.updateShowProgressBar(false)
this.lastRemoteRefreshSuccessTimestamp = new Date()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default defineComponent({
},
data: function () {
return {
isLoading: false,
isLoading: true,
videoList: [],
errorChannels: [],
attemptedFetch: false,
Expand Down Expand Up @@ -105,8 +105,6 @@ export default defineComponent({
},
},
mounted: async function () {
this.isLoading = true

this.loadVideosFromCacheSometimes()
},
methods: {
Expand All @@ -124,12 +122,10 @@ export default defineComponent({
},

async loadVideosFromCacheForAllActiveProfileChannels() {
const videoList = []
this.activeSubscriptionList.forEach((channel) => {
const channelCacheEntry = this.$store.getters.getShortsCacheByChannel(channel.id)

videoList.push(...channelCacheEntry.videos)
const videoList = this.cacheEntriesForAllActiveProfileChannels.flatMap((cacheEntry) => {
return cacheEntry.videos
})

this.videoList = updateVideoListAfterProcessing(videoList)
this.isLoading = false
},
Expand All @@ -142,7 +138,6 @@ export default defineComponent({
}

const channelsToLoadFromRemote = this.activeSubscriptionList
const videoList = []
let channelCount = 0
this.isLoading = true
this.updateShowProgressBar(true)
Expand Down Expand Up @@ -178,10 +173,9 @@ export default defineComponent({
}

return videos
}))).flatMap((o) => o)
videoList.push(...videoListFromRemote)
}))).flat()

this.videoList = updateVideoListAfterProcessing(videoList)
this.videoList = updateVideoListAfterProcessing(videoListFromRemote)
this.isLoading = false
this.updateShowProgressBar(false)
this.lastRemoteRefreshSuccessTimestamp = new Date()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default defineComponent({
},
data: function () {
return {
isLoading: false,
isLoading: true,
videoList: [],
errorChannels: [],
attemptedFetch: false,
Expand Down Expand Up @@ -115,8 +115,6 @@ export default defineComponent({
},
},
mounted: async function () {
this.isLoading = true

this.loadVideosFromCacheSometimes()
},
methods: {
Expand All @@ -134,12 +132,10 @@ export default defineComponent({
},

async loadVideosFromCacheForAllActiveProfileChannels() {
const videoList = []
this.activeSubscriptionList.forEach((channel) => {
const channelCacheEntry = this.$store.getters.getVideoCacheByChannel(channel.id)

videoList.push(...channelCacheEntry.videos)
const videoList = this.cacheEntriesForAllActiveProfileChannels.flatMap((cacheEntry) => {
return cacheEntry.videos
})

this.videoList = updateVideoListAfterProcessing(videoList)
this.isLoading = false
},
Expand All @@ -152,7 +148,6 @@ export default defineComponent({
}

const channelsToLoadFromRemote = this.activeSubscriptionList
const videoList = []
let channelCount = 0
this.isLoading = true

Expand Down Expand Up @@ -206,10 +201,9 @@ export default defineComponent({
}

return videos
}))).flatMap((o) => o)
videoList.push(...videoListFromRemote)
}))).flat()

this.videoList = updateVideoListAfterProcessing(videoList)
this.videoList = updateVideoListAfterProcessing(videoListFromRemote)
this.isLoading = false
this.updateShowProgressBar(false)
this.lastRemoteRefreshSuccessTimestamp = new Date()
Expand Down

0 comments on commit b1861ff

Please sign in to comment.