Skip to content

Commit

Permalink
Update to show # of channels updated out of total
Browse files Browse the repository at this point in the history
  • Loading branch information
kommunarr committed Nov 28, 2023
1 parent 515597b commit d589150
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 14 deletions.
18 changes: 18 additions & 0 deletions src/renderer/components/ft-refresh-widget/ft-refresh-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,29 @@ export default defineComponent({
title: {
type: String,
required: true
},
updatedChannelsCount: {
type: Number,
default: 0
},
totalChannelsCount: {
type: Number,
default: 0
}
},
computed: {
isSideNavOpen: function () {
return this.$store.getters.getIsSideNavOpen
},
lastRefreshTimestampLabel: function () {
return this.updatedChannelsCount === this.totalChannelsCount
? this.$t('Feed.Feed Last Updated', { feedName: this.title, date: this.lastRefreshTimestamp })
: this.$t('Feed.Feed Last Updated For Channels', {
feedName: this.title,
date: this.lastRefreshTimestamp,
someChannelsCount: this.updatedChannelsCount,
allChannelsCount: this.totalChannelsCount
})
}
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
v-if="lastRefreshTimestamp"
class="lastRefreshTimestamp"
>
{{ $t('Feed.Feed Last Updated', { feedName: title, date: lastRefreshTimestamp }) }}
{{ lastRefreshTimestampLabel }}
</p>
<ft-icon-button
:disabled="disableRefresh"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default defineComponent({
postList: [],
errorChannels: [],
attemptedFetch: false,
updatedChannelsCount: 0
}
},
computed: {
Expand Down Expand Up @@ -58,9 +59,12 @@ export default defineComponent({
if (this.cacheEntriesForAllActiveProfileChannels.length === 0) { return false }
if (this.cacheEntriesForAllActiveProfileChannels.length < this.activeSubscriptionList.length) { return false }

return this.cacheEntriesForAllActiveProfileChannels.every((cacheEntry) => {
return cacheEntry.posts != null
})
return this.nonNullCacheEntriesCount < this.cacheEntriesForAllActiveProfileChannels.length
},

nonNullCacheEntriesCount() {
return this.cacheEntriesForAllActiveProfileChannels
.filter((cacheEntry) => cacheEntry.posts != null).length
},

activeSubscriptionList: function () {
Expand All @@ -84,6 +88,7 @@ export default defineComponent({
this.isLoading = true
// This method is called on view visible
if (!this.fetchSubscriptionsAutomatically || this.postCacheForAllActiveProfileChannelsPresent) {
this.updatedChannelsCount = this.nonNullCacheEntriesCount
this.loadPostsFromCacheForActiveProfileChannels()
if (this.cacheEntriesForAllActiveProfileChannels.length > 0) {
let minTimestamp = null
Expand Down Expand Up @@ -115,6 +120,8 @@ export default defineComponent({
},

loadPostsForSubscriptionsFromRemote: async function () {
this.updatedChannelsCount = this.activeSubscriptionList.length

if (this.activeSubscriptionList.length === 0) {
this.isLoading = false
this.postList = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
:is-community="true"
:initial-data-limit="20"
:last-refresh-timestamp="lastCommunityRefreshTimestamp"
:updated-channels-count="updatedChannelsCount"
:total-channels-count="activeSubscriptionList.length"
:title="$t('Global.Community')"
@refresh="loadPostsForSubscriptionsFromRemote"
/>
Expand Down
11 changes: 8 additions & 3 deletions src/renderer/components/subscriptions-live/subscriptions-live.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default defineComponent({
videoList: [],
errorChannels: [],
attemptedFetch: false,
updatedChannelsCount: 0
}
},
computed: {
Expand Down Expand Up @@ -58,9 +59,11 @@ export default defineComponent({
if (this.cacheEntriesForAllActiveProfileChannels.length === 0) { return false }
if (this.cacheEntriesForAllActiveProfileChannels.length < this.activeSubscriptionList.length) { return false }

return this.cacheEntriesForAllActiveProfileChannels.every((cacheEntry) => {
return cacheEntry.videos != null
})
return this.nonNullCacheEntriesCount < this.cacheEntriesForAllActiveProfileChannels.length
},
nonNullCacheEntriesCount() {
return this.cacheEntriesForAllActiveProfileChannels
.filter((cacheEntry) => cacheEntry.videos != null).length
},

activeSubscriptionList: function () {
Expand Down Expand Up @@ -88,6 +91,8 @@ export default defineComponent({
this.updateLastLiveRefreshTimestampByProfile(payload)
},
loadVideosForSubscriptionsFromRemote: async function () {
this.updatedChannelsCount = this.activeSubscriptionList.length

if (this.activeSubscriptionList.length === 0) {
this.isLoading = false
this.videoList = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
:error-channels="errorChannels"
:attempted-fetch="attemptedFetch"
:last-refresh-timestamp="lastLiveRefreshTimestamp"
:updated-channels-count="updatedChannelsCount"
:total-channels-count="activeSubscriptionList.length"
:title="$t('Global.Live')"
@refresh="loadVideosForSubscriptionsFromRemote"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default defineComponent({
videoList: [],
errorChannels: [],
attemptedFetch: false,
updatedChannelsCount: 0
}
},
computed: {
Expand Down Expand Up @@ -56,9 +57,11 @@ export default defineComponent({
if (this.cacheEntriesForAllActiveProfileChannels.length === 0) { return false }
if (this.cacheEntriesForAllActiveProfileChannels.length < this.activeSubscriptionList.length) { return false }

return this.cacheEntriesForAllActiveProfileChannels.every((cacheEntry) => {
return cacheEntry.videos != null
})
return this.nonNullCacheEntriesCount < this.cacheEntriesForAllActiveProfileChannels.length
},
nonNullCacheEntriesCount() {
return this.cacheEntriesForAllActiveProfileChannels
.filter((cacheEntry) => cacheEntry.videos != null).length
},

activeSubscriptionList: function () {
Expand All @@ -82,6 +85,8 @@ export default defineComponent({
this.updateLastShortRefreshTimestampByProfile(payload)
},
loadVideosForSubscriptionsFromRemote: async function () {
this.updatedChannelsCount = this.activeSubscriptionList.length

if (this.activeSubscriptionList.length === 0) {
this.isLoading = false
this.videoList = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
:error-channels="errorChannels"
:attempted-fetch="attemptedFetch"
:last-refresh-timestamp="lastShortRefreshTimestamp"
:updated-channels-count="updatedChannelsCount"
:total-channels-count="activeSubscriptionList.length"
:title="$t('Global.Shorts')"
@refresh="loadVideosForSubscriptionsFromRemote"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ export default defineComponent({
title: {
type: String,
required: true
},
updatedChannelsCount: {
type: Number,
default: 0
},
totalChannelsCount: {
type: Number,
default: 0
}
},
data: function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<ft-refresh-widget
:disable-refresh="isLoading"
:last-refresh-timestamp="lastRefreshTimestamp"
:updated-channels-count="updatedChannelsCount"
:total-channels-count="totalChannelsCount"
:title="title"
@click="$emit('refresh')"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default defineComponent({
videoList: [],
errorChannels: [],
attemptedFetch: false,
updatedChannelsCount: 0
}
},
computed: {
Expand Down Expand Up @@ -66,9 +67,11 @@ export default defineComponent({
if (this.cacheEntriesForAllActiveProfileChannels.length === 0) { return false }
if (this.cacheEntriesForAllActiveProfileChannels.length < this.activeSubscriptionList.length) { return false }

return this.cacheEntriesForAllActiveProfileChannels.every((cacheEntry) => {
return cacheEntry.videos != null
})
return this.nonNullCacheEntriesCount < this.cacheEntriesForAllActiveProfileChannels.length
},
nonNullCacheEntriesCount() {
return this.cacheEntriesForAllActiveProfileChannels
.filter((cacheEntry) => cacheEntry.videos != null).length
},

activeSubscriptionList: function () {
Expand All @@ -92,6 +95,8 @@ export default defineComponent({
this.updateLastVideoRefreshTimestampByProfile(payload)
},
loadVideosForSubscriptionsFromRemote: async function () {
this.updatedChannelsCount = this.activeSubscriptionList.length

if (this.activeSubscriptionList.length === 0) {
this.isLoading = false
this.videoList = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
:video-list="videoList"
:error-channels="errorChannels"
:last-refresh-timestamp="lastVideoRefreshTimestamp"
:updated-channels-count="updatedChannelsCount"
:total-channels-count="activeSubscriptionList.length"
:attempted-fetch="attemptedFetch"
:title="$t('Global.Videos')"
@refresh="loadVideosForSubscriptionsFromRemote"
Expand Down
5 changes: 4 additions & 1 deletion src/renderer/helpers/subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export async function loadSubscriptionVideosFromCacheOrServer(subscriptionCompon
if (!subscriptionComponent.fetchSubscriptionsAutomatically || subscriptionComponent.videoCacheForAllActiveProfileChannelsPresent) {
loadVideosFromCacheForActiveProfileChannels(subscriptionComponent)
if (subscriptionComponent.cacheEntriesForAllActiveProfileChannels.length > 0) {
subscriptionComponent.updatedChannelsCount = subscriptionComponent.nonNullCacheEntriesCount
let minTimestamp = null
subscriptionComponent.cacheEntriesForAllActiveProfileChannels.forEach((cacheEntry) => {
if (!minTimestamp || cacheEntry.timestamp.getTime() < minTimestamp.getTime()) {
Expand All @@ -165,7 +166,9 @@ export async function loadSubscriptionVideosFromCacheOrServer(subscriptionCompon
export async function loadVideosFromCacheForActiveProfileChannels(subscriptionComponent) {
const videoList = []
subscriptionComponent.cacheEntriesForAllActiveProfileChannels.forEach((channelCacheEntry) => {
videoList.push(...channelCacheEntry.videos)
if (channelCacheEntry.videos != null) {
videoList.push(...channelCacheEntry.videos)
}
})
subscriptionComponent.videoList = updateVideoListAfterProcessing(videoList)
subscriptionComponent.isLoading = false
Expand Down
1 change: 1 addition & 0 deletions static/locales/en-US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ Trending:
Most Popular: Most Popular
Feed:
Feed Last Updated: '{feedName} feed last updated: {date}'
Feed Last Updated For Channels: '{feedName} feed last updated for {someChannelsCount}/{allChannelsCount} channels: {date}'
Refresh Feed: Refresh {subscriptionName}
Playlists: Playlists
User Playlists:
Expand Down

0 comments on commit d589150

Please sign in to comment.