From 5c9ac912ac92129d8aff567ad69e39ceb7d52745 Mon Sep 17 00:00:00 2001 From: Aayush Gupta Date: Wed, 3 Dec 2025 16:44:41 +0800 Subject: [PATCH 1/2] StreamHistoryDAO: Latest entry can be null Signed-off-by: Aayush Gupta --- .../org/schabi/newpipe/database/history/dao/StreamHistoryDAO.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/database/history/dao/StreamHistoryDAO.kt b/app/src/main/java/org/schabi/newpipe/database/history/dao/StreamHistoryDAO.kt index 432c93a55..916d4e5ed 100644 --- a/app/src/main/java/org/schabi/newpipe/database/history/dao/StreamHistoryDAO.kt +++ b/app/src/main/java/org/schabi/newpipe/database/history/dao/StreamHistoryDAO.kt @@ -35,7 +35,7 @@ abstract class StreamHistoryDAO : BasicDAO { abstract val historySortedById: Flowable> @Query("SELECT * FROM stream_history WHERE stream_id = :streamId ORDER BY access_date DESC LIMIT 1") - abstract fun getLatestEntry(streamId: Long): StreamHistoryEntity + abstract fun getLatestEntry(streamId: Long): StreamHistoryEntity? @Query("DELETE FROM stream_history WHERE stream_id = :streamId") abstract fun deleteStreamHistory(streamId: Long): Int From 4a00dbb15d5dcd16a7d7f139f88b9b572a9c722d Mon Sep 17 00:00:00 2001 From: Aayush Gupta Date: Wed, 3 Dec 2025 17:19:28 +0800 Subject: [PATCH 2/2] Don't swallow error when trying to mark stream as watched Signed-off-by: Aayush Gupta --- .../fragments/detail/VideoDetailFragment.java | 8 +++++++- .../info_list/dialog/StreamDialogDefaultEntry.java | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index b5ce07c56..a07e9c06e 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -1230,7 +1230,13 @@ public final class VideoDetailFragment disposables.add(recordManager.onViewed(info).onErrorComplete() .subscribe( ignored -> { /* successful */ }, - error -> Log.e(TAG, "Register view failure: ", error) + error -> showSnackBarError( + new ErrorInfo( + error, + UserAction.PLAY_STREAM, + "Got an error when modifying history on viewed" + ) + ) )); } diff --git a/app/src/main/java/org/schabi/newpipe/info_list/dialog/StreamDialogDefaultEntry.java b/app/src/main/java/org/schabi/newpipe/info_list/dialog/StreamDialogDefaultEntry.java index c7ac9556f..a2bf4a1ff 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/dialog/StreamDialogDefaultEntry.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/dialog/StreamDialogDefaultEntry.java @@ -13,6 +13,9 @@ import androidx.annotation.StringRes; import org.schabi.newpipe.R; import org.schabi.newpipe.database.stream.model.StreamEntity; import org.schabi.newpipe.download.DownloadDialog; +import org.schabi.newpipe.error.ErrorInfo; +import org.schabi.newpipe.error.ErrorUtil; +import org.schabi.newpipe.error.UserAction; import org.schabi.newpipe.local.dialog.PlaylistAppendDialog; import org.schabi.newpipe.local.dialog.PlaylistDialog; import org.schabi.newpipe.local.history.HistoryRecordManager; @@ -132,6 +135,16 @@ public enum StreamDialogDefaultEntry { MARK_AS_WATCHED(R.string.mark_as_watched, (fragment, item) -> new HistoryRecordManager(fragment.getContext()) .markAsWatched(item) + .doOnError(error -> { + ErrorUtil.showSnackbar( + fragment.requireContext(), + new ErrorInfo( + error, + UserAction.OPEN_INFO_ITEM_DIALOG, + "Got an error when trying to mark as watched" + ) + ); + }) .onErrorComplete() .observeOn(AndroidSchedulers.mainThread()) .subscribe()