Skip to content

Commit f6aa7ef

Browse files
authored
fix: bound time remaining to mark a video as watched (libre-tube#7173)
1 parent 71288ec commit f6aa7ef

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

app/src/main/java/com/github/libretube/db/DatabaseHelper.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ import kotlinx.coroutines.withContext
1515
object DatabaseHelper {
1616
private const val MAX_SEARCH_HISTORY_SIZE = 20
1717

18+
// can only mark as watched if less than 60s remaining
19+
private const val ABSOLUTE_WATCHED_THRESHOLD = 60.0f
20+
21+
// can only mark as watched if at least 75% watched
22+
private const val RELATIVE_WATCHED_THRESHOLD = 0.75f
23+
1824
suspend fun addToWatchHistory(watchHistoryItem: WatchHistoryItem) =
1925
withContext(Dispatchers.IO) {
2026
Database.watchHistoryDao().insert(watchHistoryItem)
@@ -79,8 +85,8 @@ object DatabaseHelper {
7985
if (durationSeconds == null) return false
8086

8187
val progress = positionMillis / 1000
82-
// show video only in feed when watched less than 90%
83-
return progress > 0.9f * durationSeconds
88+
89+
return durationSeconds - progress <= ABSOLUTE_WATCHED_THRESHOLD && progress >= RELATIVE_WATCHED_THRESHOLD * durationSeconds
8490
}
8591

8692
suspend fun filterUnwatched(streams: List<StreamItem>): List<StreamItem> {

0 commit comments

Comments
 (0)