Repository navigation
Conversation
The phone EditProfileViewModel had the same explicitNulls=false trap we fixed on TV this session. Disabling a PIN sent pin=null, which SiloJson omits, so the server kept the old PIN; selecting subtitles "Off" mapped to null, likewise omitted, so the prior mode stuck. Port the TV fix: track loadedHasPin and send an explicit "" to clear a PIN, and send the literal "off" for subtitle mode. Matches TvEditProfileViewModel. Co-Authored-By: Claude Fable 5 <[email protected]>
📝 WalkthroughWalkthroughEditProfileViewModel now tracks whether a loaded profile previously had a PIN via a loadedHasPin flag, using it to decide whether to send the entered PIN, an explicit empty string to clear it, or null to leave it unchanged. Subtitle mode "Off" now sends "off" instead of null. ChangesProfile Update Request Serialization
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/profiles/EditProfileViewModel.kt (1)
148-155: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueThe
"Off"special-case branch is redundant.
"Off".lowercase().replace(" ", "_")already yields"off", so the explicit branch produces the same wire value as theelsebranch. The pre-fix bug was mapping"Off"tonull; now that it maps to a real value, the conditional can be collapsed. Keeping it is harmless, but it may mislead future readers into thinking"Off"needs distinct handling.♻️ Optional simplification
- // "Off" must go over the wire as the explicit "off" value, not null: - // explicitNulls=false drops a null subtitle_mode so the server would - // keep the previous mode instead of switching subtitles off. - it.copy(subtitleMode = if (mode == "Off") "off" else mode.lowercase().replace(" ", "_")) + // Normalize to the wire value (e.g. "Off" -> "off"). A real value is + // required because explicitNulls=false drops a null subtitle_mode, so + // the server would otherwise keep the previous mode. + it.copy(subtitleMode = mode.lowercase().replace(" ", "_"))🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/profiles/EditProfileViewModel.kt` around lines 148 - 155, The special-case handling in EditProfileViewModel.onSubtitleModeSelected is redundant because the "Off" option already normalizes to the same wire value as the general branch. Simplify the subtitleMode assignment by removing the explicit "Off" conditional and using the shared lowercase/underscore normalization path for all values, while keeping the explicit non-null wire value behavior intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/profiles/EditProfileViewModel.kt`:
- Around line 148-155: The special-case handling in
EditProfileViewModel.onSubtitleModeSelected is redundant because the "Off"
option already normalizes to the same wire value as the general branch. Simplify
the subtitleMode assignment by removing the explicit "Off" conditional and using
the shared lowercase/underscore normalization path for all values, while keeping
the explicit non-null wire value behavior intact.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b1282b72-5294-4de3-bb4e-9da323ff6cbc
📒 Files selected for processing (1)
androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/profiles/EditProfileViewModel.kt
|
Superseded by #52, which folds this profile PIN/subtitle fix (as commit |
The phone
EditProfileViewModelcarried the sameexplicitNulls=falsetrap that PR #50 fixed on the TV app but never ported to phone. Two edit-flow bugs:pin = null, which SiloJson omits from the PUT, so the server kept the old PIN. Now tracksloadedHasPinand sends an explicit""to clear (server treats""as clear,null/omitted as unchanged).null, likewise omitted, so the previous mode stuck. Now sends the literal"off".Both are straight ports of
TvEditProfileViewModel's already-correct handling (theloadedHasPin → ""PIN mapping and the"off"subtitle mapping). Create and delete flows were already correct on both platforms and are untouched.Gated on
:androidApp:assembleDebug+./gradlew test(debug + release unit suites) — all green.🤖 Generated with Claude Code
Summary by CodeRabbit