Skip to content

Commit 4b72084

Browse files
palharesfabsidue
andauthored
[Feature]: Hide videos immediately when marking as watched (#7866)
* Add computed properties for history cache and filtered video list * Refactor activeVideoList to use filteredVideoList and exclude watched videos from videoList * Creating a computed property to de-couple filteredVideoList from the store getters (SRP) * Transferred filtering logic to SubscriptionsTabUi component * Fix variable name * Don't try to filter videos on the posts tab --------- Co-authored-by: absidue <[email protected]>
1 parent ad1ca7d commit 4b72084

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

src/renderer/components/SubscriptionsTabUi/SubscriptionsTabUi.vue

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ const subscriptionLimit = sessionStorage.getItem('subscriptionLimit')
125125
const dataLimit = ref(subscriptionLimit !== null ? parseInt(subscriptionLimit) : props.initialDataLimit)
126126
127127
const activeVideoList = computed(() => {
128-
if (props.videoList.length < dataLimit.value) {
129-
return props.videoList
128+
if (filteredVideoList.value.length < dataLimit.value) {
129+
return filteredVideoList.value
130130
} else {
131-
return props.videoList.slice(0, dataLimit.value)
131+
return filteredVideoList.value.slice(0, dataLimit.value)
132132
}
133133
})
134134
@@ -141,6 +141,24 @@ const fetchSubscriptionsAutomatically = computed(() => {
141141
return store.getters.getFetchSubscriptionsAutomatically
142142
})
143143
144+
const historyCacheById = computed(() => {
145+
return store.getters.getHistoryCacheById
146+
})
147+
148+
const hideWatchedSubs = computed(() => {
149+
return store.getters.getHideWatchedSubs
150+
})
151+
152+
const filteredVideoList = computed(() => {
153+
if (hideWatchedSubs.value && !props.isCommunity) {
154+
return props.videoList.filter((video) => {
155+
return !Object.hasOwn(historyCacheById.value, video.videoId)
156+
})
157+
} else {
158+
return props.videoList
159+
}
160+
})
161+
144162
function increaseLimit() {
145163
dataLimit.value += props.initialDataLimit
146164
sessionStorage.setItem('subscriptionLimit', dataLimit.value.toFixed(0))

src/renderer/helpers/subscriptions.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,6 @@ export function updateVideoListAfterProcessing(videos) {
3131
})
3232
}
3333

34-
if (store.getters.getHideWatchedSubs) {
35-
const historyCacheById = store.getters.getHistoryCacheById
36-
37-
videoList = videoList.filter((video) => {
38-
return !Object.hasOwn(historyCacheById, video.videoId)
39-
})
40-
}
41-
4234
// ordered last to show first eligible video from channel
4335
// if the first one incidentally failed one of the above checks
4436
if (store.getters.getOnlyShowLatestFromChannel) {

0 commit comments

Comments
 (0)