@@ -27,6 +27,7 @@ class ShowMenuHelperViewModel(
2727 R .id.menu_remove_download to false ,
2828 R .id.menu_cancel_download to false ,
2929 R .id.menu_mark_unwatched to false ,
30+ R .id.menu_mark_watched to true ,
3031 R .id.menu_add_bookmark to true ,
3132 R .id.menu_remove_bookmark to false
3233 )
@@ -40,7 +41,7 @@ class ShowMenuHelperViewModel(
4041
4142 fun getMenuItemsVisibility (show : MediathekShow ): Flow <Map <Int , Boolean >> {
4243 return mediathekRepository
43- .getPersistedShowByApiId (show.apiId )
44+ .persistOrUpdateShow (show)
4445 .mapLatest {
4546 lastMapping = mapOf (
4647 R .id.menu_share to true ,
@@ -63,17 +64,12 @@ class ShowMenuHelperViewModel(
6364 DownloadStatus .PAUSED ,
6465 )),
6566 R .id.menu_mark_unwatched to (it.playbackPosition > 0 ),
67+ R .id.menu_mark_watched to (it.playbackPosition < it.videoDuration),
6668 R .id.menu_add_bookmark to ! it.isBookmarked,
6769 R .id.menu_remove_bookmark to it.isBookmarked
6870 )
6971 lastMapping
7072 }
71- .onStart {
72- // for when the show has not yet been persisted
73- emit(defaultMapping.toMutableMap().apply {
74- this [R .id.menu_start_download] = show.hasAnyDownloadQuality()
75- })
76- }
7773 .distinctUntilChanged()
7874 }
7975
@@ -99,9 +95,11 @@ class ShowMenuHelperViewModel(
9995 mediathekRepository.resetPlaybackPosition(show.apiId)
10096 }
10197
98+ suspend fun markWatched (show : MediathekShow ) {
99+ mediathekRepository.markAsPlayed(show.apiId)
100+ }
101+
102102 suspend fun bookmark (show : MediathekShow ) {
103- // we need to persist this first, because it might not yet be persisted!
104- mediathekRepository.persistOrUpdateShow(show)
105103 mediathekRepository.setBookmarked(show.apiId, true )
106104 }
107105
@@ -110,8 +108,7 @@ class ShowMenuHelperViewModel(
110108 }
111109
112110 suspend fun startDownload (show : MediathekShow , quality : Quality ) {
113- // we need to persist this first, because it might not yet be persisted!
114- val persistedShow = mediathekRepository.persistOrUpdateShow(show).first()
111+ val persistedShow = mediathekRepository.getPersistedShowByApiId(show.apiId).first()
115112 downloadController.startDownload(persistedShow.id, quality)
116113 }
117114}
0 commit comments