Repository navigation
feat(settings): hide spoilers for unwatched episodes, per profile #427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e8f905a
3a7b017
838035a
5ea9a58
9431eab
968c82c
fa98b14
155eccc
668e887
c7f547b
5f52d52
96b7f70
4aa9c61
e559c5f
07c384d
353ac27
63258b0
6158463
e6446f5
eae8f4f
590f092
84a95de
efb5a0a
9478b55
4b6a4e7
8b4a118
a68c70c
5ab98ba
e1a4b8c
002cfa6
c57fcc8
b8e4677
4d8eaa7
994c31b
01bb7fd
917bf61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package org.siloserver.silo.common.cards | ||
|
|
||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.CompositionLocalProvider | ||
| import androidx.compose.runtime.LaunchedEffect | ||
| import androidx.compose.runtime.ProvidableCompositionLocal | ||
| import androidx.compose.runtime.collectAsState | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.runtime.staticCompositionLocalOf | ||
| import org.siloserver.silo.common.settings.EpisodeSpoilerStore | ||
| import org.siloserver.silo.model.settings.EpisodeSpoilerPrefs | ||
|
|
||
| /** | ||
| * The profile's spoiler protection for unwatched episodes, published once | ||
| * near each app shell. Surfaces pair it with | ||
| * [org.siloserver.silo.model.settings.EpisodeSpoilers.isUnwatched] to decide | ||
| * per episode. Outside a [ProvideEpisodeSpoilerPrefs] scope nothing is hidden. | ||
| */ | ||
| val LocalEpisodeSpoilerPrefs: ProvidableCompositionLocal<EpisodeSpoilerPrefs> = | ||
| staticCompositionLocalOf { EpisodeSpoilerPrefs.NONE } | ||
|
|
||
| /** | ||
| * Hydrates the [store] for [sessionKey] (the active profile id) and publishes | ||
| * its resolved prefs via [LocalEpisodeSpoilerPrefs]. Keyed on the session for | ||
| * the same reason as [ProvideCardPresentation]: the provider is first | ||
| * composed on the unauthenticated Login screen. | ||
| */ | ||
| @Composable | ||
| fun ProvideEpisodeSpoilerPrefs( | ||
| store: EpisodeSpoilerStore, | ||
| sessionKey: Any? = null, | ||
| content: @Composable () -> Unit, | ||
| ) { | ||
| LaunchedEffect(store, sessionKey) { | ||
| if (sessionKey != null) store.hydrateIfNeeded() | ||
| } | ||
| val state by store.state.collectAsState() | ||
| CompositionLocalProvider(LocalEpisodeSpoilerPrefs provides state.prefs, content = content) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,16 @@ interface DirtyOperationDao { | |
| "AND targetContentId = :contentId AND opKind IN ('SET_WATCHED', 'SET_RATING', 'SET_POSITION', 'PERSONAL_V2')") | ||
| suspend fun unresolvedPersonalCount(serverId: String, profileId: String, contentId: String): Int | ||
|
|
||
| @Query("SELECT contentId FROM content_item_state WHERE serverId = :serverId AND profileId = :profileId " + | ||
| "AND contentId IN (:contentIds) AND watchedUpdatedAtMs >= :sinceMs " + | ||
| "UNION SELECT contentId FROM user_item_state WHERE serverId = :serverId AND profileId = :profileId " + | ||
| "AND contentId IN (:contentIds) AND positionUpdatedAtMs >= :sinceMs " + | ||
| "UNION SELECT targetContentId FROM dirty_operations WHERE serverId = :serverId AND profileId = :profileId " + | ||
| "AND targetContentId IN (:contentIds) AND opKind IN ('SET_WATCHED', 'SET_POSITION')") | ||
|
Comment on lines
+32
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a user marks a downloaded episode unwatched from Home or a catalog card and opens Downloads before that request settles, the current personal-write path inserts a Useful? React with 👍 / 👎.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not changing this. The fix would show a pending write's desired value before the server confirms it, which the personal-write model rules out on purpose. While the write is in flight, the pre-write state is still the confirmed one. Once it's acknowledged, |
||
| suspend fun contentIdsWithPendingOrNewerUserState( | ||
| serverId: String, profileId: String, contentIds: List<String>, sinceMs: Long, | ||
| ): List<String> | ||
|
|
||
| /** A newer desired-state write supersedes any v2 personal row the previous attempt left behind. */ | ||
| @Query("DELETE FROM dirty_operations WHERE opKind = 'PERSONAL_V2' AND serverId = :serverId " + | ||
| "AND profileId = :profileId AND targetContentId = :contentId") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reconciliation can overwrite pending local watched or playback intent because the unresolved-operation query excludes PERSONAL_V2, although the DAO already recognizes those rows as unresolved personal writes; a write admitted before sinceMs can miss both timestamp branches and the outbox branch. Include PERSONAL_V2 in the unresolved-operation branch to preserve the item's local state until its write resolves.
Kody rule violation: Use genuinely fresh reconciliation reads without overwriting newer local intent
Prompt for LLM
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not changing this. A
PERSONAL_V2row inpersonal_uncertainprojects nothing into Room until the server acknowledges it.completePersonalWritethen writeswatchedUpdatedAtMs = now()and clears progress at that time, so an acknowledgement after the snapshot started falls in thewatchedUpdatedAtMs >= :sinceMsbranch. While the write is still in flight, Room holds only the pre-write state, so preferring it over the snapshot would show older data.PERSONAL_V2also covers ratings, which must not mask the server's watch state (ratingsAndTrackChangesDoNotPromoteStaleWatchState).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed—the suggestion conflated an unresolved write with local watch state already projected into Room.
Under the behavior you described:
PERSONAL_V2write inpersonal_uncertainleaves Room holding pre-write state. Protecting that state from reconciliation could preserve stale data.completePersonalWritestampswatchedUpdatedAtMs, so the existing timestamp branch protects the acknowledged watched/progress reset.PERSONAL_V2operations would also let rating-only writes incorrectly shield stale watch state, contrary toratingsAndTrackChangesDoNotPromoteStaleWatchState.I withdraw the recommendation to add
PERSONAL_V2to this query. The unresolved-operation branch should protect pending projected watch/progress state—not every unresolved personal operation. No code change is warranted for the concern I raised.