diff --git a/app/src/main/java/com/github/libretube/extensions/FilterUntil.kt b/app/src/main/java/com/github/libretube/extensions/FilterUntil.kt deleted file mode 100644 index 856462a18..000000000 --- a/app/src/main/java/com/github/libretube/extensions/FilterUntil.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.github.libretube.extensions - -/** - * Returns a list of all items until the given condition is fulfilled - * @param predicate The condition which needs to be searched for - * @return a list of all items before the first true condition - */ -fun List.filterUntil(predicate: (T) -> Boolean): List? { - val items = mutableListOf() - this.forEach { - if (predicate(it)) return items - items.add(it) - } - return null -} diff --git a/app/src/main/java/com/github/libretube/workers/NotificationWorker.kt b/app/src/main/java/com/github/libretube/workers/NotificationWorker.kt index b9447238d..2ea3e01bc 100644 --- a/app/src/main/java/com/github/libretube/workers/NotificationWorker.kt +++ b/app/src/main/java/com/github/libretube/workers/NotificationWorker.kt @@ -18,7 +18,6 @@ import com.github.libretube.constants.IntentData import com.github.libretube.constants.PUSH_CHANNEL_ID import com.github.libretube.constants.PreferenceKeys import com.github.libretube.extensions.TAG -import com.github.libretube.extensions.filterUntil import com.github.libretube.extensions.toID import com.github.libretube.ui.activities.MainActivity import com.github.libretube.ui.views.TimePickerPreference @@ -107,9 +106,7 @@ class NotificationWorker(appContext: Context, parameters: WorkerParameters) : } // filter the new videos until the last seen video in the feed - val newStreams = videoFeed.filterUntil { - it.url!!.toID() == lastSeenStreamId - } ?: return@runBlocking + val newStreams = videoFeed.takeWhile { it.url!!.toID() != lastSeenStreamId } // return if the previous video didn't get found if (newStreams.isEmpty()) return@runBlocking