Skip to content

Commit e68d49e

Browse files
committed
Do not fetch all streams when disabling notifications for a channel
1 parent 01f3ed0 commit e68d49e

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionManager.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ class SubscriptionManager(context: Context) {
7575
Completable.fromAction {
7676
entity.notificationMode = mode
7777
subscriptionTable().update(entity)
78-
}.andThen(rememberLastStream(entity))
78+
}.apply {
79+
if (mode != NotificationMode.DISABLED) {
80+
// notifications have just been enabled, mark all streams as "old"
81+
andThen(rememberAllStreams(entity))
82+
}
83+
}
7984
}
8085
}
8186

@@ -108,7 +113,12 @@ class SubscriptionManager(context: Context) {
108113
subscriptionTable.delete(subscriptionEntity)
109114
}
110115

111-
private fun rememberLastStream(subscription: SubscriptionEntity): Completable {
116+
/**
117+
* Fetches the list of videos for the provided channel and saves them in the database, so that
118+
* they will be considered as "old"/"already seen" streams and the user will never notified
119+
* about any one of them.
120+
*/
121+
private fun rememberAllStreams(subscription: SubscriptionEntity): Completable {
112122
return ExtractorHelper.getChannelInfo(subscription.serviceId, subscription.url, false)
113123
.map { channel -> channel.relatedItems.map { stream -> StreamEntity(stream) } }
114124
.flatMapCompletable { entities ->

0 commit comments

Comments
 (0)