From 70d5b3453f60f329298292683108d7aca4d8e566 Mon Sep 17 00:00:00 2001 From: Preston Date: Mon, 28 Sep 2020 20:48:20 -0400 Subject: [PATCH] Update Subscription List when changing profiles in a different view --- src/renderer/themes.css | 1 + .../views/Subscriptions/Subscriptions.js | 68 +++++++++++-------- 2 files changed, 39 insertions(+), 30 deletions(-) diff --git a/src/renderer/themes.css b/src/renderer/themes.css index 6f054d34..7ac79dcd 100644 --- a/src/renderer/themes.css +++ b/src/renderer/themes.css @@ -472,6 +472,7 @@ a:visited { ::-webkit-scrollbar-thumb { background: var(--scrollbar-color); border-radius: 6px; + height: 6px; } ::-webkit-scrollbar-thumb:hover { diff --git a/src/renderer/views/Subscriptions/Subscriptions.js b/src/renderer/views/Subscriptions/Subscriptions.js index d6f1350a..b84f7a86 100644 --- a/src/renderer/views/Subscriptions/Subscriptions.js +++ b/src/renderer/views/Subscriptions/Subscriptions.js @@ -86,27 +86,7 @@ export default Vue.extend({ }, watch: { activeProfile: async function (val) { - if (this.allSubscriptionsList.length !== 0) { - this.isLoading = true - this.videoList = await Promise.all(this.allSubscriptionsList.filter((video) => { - const channelIndex = this.activeSubscriptionList.findIndex((x) => { - return x.id === video.authorId - }) - - const historyIndex = this.historyCache.findIndex((x) => { - return x.videoId === video.videoId - }) - - if (this.hideWatchedSubs) { - return channelIndex !== -1 && historyIndex === -1 - } else { - return channelIndex !== -1 - } - })) - this.isLoading = false - } else { - this.getSubscriptions() - } + this.getProfileSubscriptions() } }, mounted: async function () { @@ -117,17 +97,21 @@ export default Vue.extend({ } if (this.profileSubscriptions.videoList.length !== 0) { - const subscriptionList = JSON.parse(JSON.stringify(this.profileSubscriptions)) - if (this.hideWatchedSubs) { - this.videoList = await Promise.all(subscriptionList.videoList.filter((video) => { - const historyIndex = this.historyCache.findIndex((x) => { - return x.videoId === video.videoId - }) + if (this.profileSubscriptions.activeProfile === this.activeProfile) { + const subscriptionList = JSON.parse(JSON.stringify(this.profileSubscriptions)) + if (this.hideWatchedSubs) { + this.videoList = await Promise.all(subscriptionList.videoList.filter((video) => { + const historyIndex = this.historyCache.findIndex((x) => { + return x.videoId === video.videoId + }) - return historyIndex === -1 - })) + return historyIndex === -1 + })) + } else { + this.videoList = subscriptionList.videoList + } } else { - this.videoList = subscriptionList.videoList + this.getProfileSubscriptions() } this.isLoading = false @@ -205,6 +189,30 @@ export default Vue.extend({ }) }, + getProfileSubscriptions: async function () { + if (this.allSubscriptionsList.length !== 0) { + this.isLoading = true + this.videoList = await Promise.all(this.allSubscriptionsList.filter((video) => { + const channelIndex = this.activeSubscriptionList.findIndex((x) => { + return x.id === video.authorId + }) + + const historyIndex = this.historyCache.findIndex((x) => { + return x.videoId === video.videoId + }) + + if (this.hideWatchedSubs) { + return channelIndex !== -1 && historyIndex === -1 + } else { + return channelIndex !== -1 + } + })) + this.isLoading = false + } else { + this.getSubscriptions() + } + }, + getChannelVideosLocalScraper: function (channel, failedAttempts = 0) { return new Promise((resolve, reject) => { ytch.getChannelVideos(channel.id, 'latest').then(async (response) => {