Merge pull request #12864 from TeamNewPipe/historyFixes

Fixes for history
This commit is contained in:
Aayush Gupta
2025-12-04 15:28:17 +08:00
committed by GitHub
3 changed files with 21 additions and 2 deletions

View File

@@ -35,7 +35,7 @@ abstract class StreamHistoryDAO : BasicDAO<StreamHistoryEntity> {
abstract val historySortedById: Flowable<MutableList<StreamHistoryEntry>> abstract val historySortedById: Flowable<MutableList<StreamHistoryEntry>>
@Query("SELECT * FROM stream_history WHERE stream_id = :streamId ORDER BY access_date DESC LIMIT 1") @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") @Query("DELETE FROM stream_history WHERE stream_id = :streamId")
abstract fun deleteStreamHistory(streamId: Long): Int abstract fun deleteStreamHistory(streamId: Long): Int

View File

@@ -1230,7 +1230,13 @@ public final class VideoDetailFragment
disposables.add(recordManager.onViewed(info).onErrorComplete() disposables.add(recordManager.onViewed(info).onErrorComplete()
.subscribe( .subscribe(
ignored -> { /* successful */ }, 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"
)
)
)); ));
} }

View File

@@ -13,6 +13,9 @@ import androidx.annotation.StringRes;
import org.schabi.newpipe.R; import org.schabi.newpipe.R;
import org.schabi.newpipe.database.stream.model.StreamEntity; import org.schabi.newpipe.database.stream.model.StreamEntity;
import org.schabi.newpipe.download.DownloadDialog; 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.PlaylistAppendDialog;
import org.schabi.newpipe.local.dialog.PlaylistDialog; import org.schabi.newpipe.local.dialog.PlaylistDialog;
import org.schabi.newpipe.local.history.HistoryRecordManager; import org.schabi.newpipe.local.history.HistoryRecordManager;
@@ -132,6 +135,16 @@ public enum StreamDialogDefaultEntry {
MARK_AS_WATCHED(R.string.mark_as_watched, (fragment, item) -> MARK_AS_WATCHED(R.string.mark_as_watched, (fragment, item) ->
new HistoryRecordManager(fragment.getContext()) new HistoryRecordManager(fragment.getContext())
.markAsWatched(item) .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() .onErrorComplete()
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe() .subscribe()