Skip to content

Commit 3d1d7e0

Browse files
authored
Merge pull request #12864 from TeamNewPipe/historyFixes
Fixes for history
2 parents ffb82dc + 4a00dbb commit 3d1d7e0

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

app/src/main/java/org/schabi/newpipe/database/history/dao/StreamHistoryDAO.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ abstract class StreamHistoryDAO : BasicDAO<StreamHistoryEntity> {
3535
abstract val historySortedById: Flowable<MutableList<StreamHistoryEntry>>
3636

3737
@Query("SELECT * FROM stream_history WHERE stream_id = :streamId ORDER BY access_date DESC LIMIT 1")
38-
abstract fun getLatestEntry(streamId: Long): StreamHistoryEntity
38+
abstract fun getLatestEntry(streamId: Long): StreamHistoryEntity?
3939

4040
@Query("DELETE FROM stream_history WHERE stream_id = :streamId")
4141
abstract fun deleteStreamHistory(streamId: Long): Int

app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,13 @@ private void startOnExternalPlayer(@NonNull final Context context,
12301230
disposables.add(recordManager.onViewed(info).onErrorComplete()
12311231
.subscribe(
12321232
ignored -> { /* successful */ },
1233-
error -> Log.e(TAG, "Register view failure: ", error)
1233+
error -> showSnackBarError(
1234+
new ErrorInfo(
1235+
error,
1236+
UserAction.PLAY_STREAM,
1237+
"Got an error when modifying history on viewed"
1238+
)
1239+
)
12341240
));
12351241
}
12361242

app/src/main/java/org/schabi/newpipe/info_list/dialog/StreamDialogDefaultEntry.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
import org.schabi.newpipe.R;
1414
import org.schabi.newpipe.database.stream.model.StreamEntity;
1515
import org.schabi.newpipe.download.DownloadDialog;
16+
import org.schabi.newpipe.error.ErrorInfo;
17+
import org.schabi.newpipe.error.ErrorUtil;
18+
import org.schabi.newpipe.error.UserAction;
1619
import org.schabi.newpipe.local.dialog.PlaylistAppendDialog;
1720
import org.schabi.newpipe.local.dialog.PlaylistDialog;
1821
import org.schabi.newpipe.local.history.HistoryRecordManager;
@@ -132,6 +135,16 @@ public enum StreamDialogDefaultEntry {
132135
MARK_AS_WATCHED(R.string.mark_as_watched, (fragment, item) ->
133136
new HistoryRecordManager(fragment.getContext())
134137
.markAsWatched(item)
138+
.doOnError(error -> {
139+
ErrorUtil.showSnackbar(
140+
fragment.requireContext(),
141+
new ErrorInfo(
142+
error,
143+
UserAction.OPEN_INFO_ITEM_DIALOG,
144+
"Got an error when trying to mark as watched"
145+
)
146+
);
147+
})
135148
.onErrorComplete()
136149
.observeOn(AndroidSchedulers.mainThread())
137150
.subscribe()

0 commit comments

Comments
 (0)