You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 91be8b7
Browse filesBrowse the repository at this point in the historyBrowse files
feat(user-profile): gate Save on a real edit and discard it on back (#1350)
* feat(user-profile): gate Save on a real edit and discard it on back
The name and username steps seeded their field from the stored profile and
then enabled the confirm button on any non-blank text, so opening either one
armed Save before the user had changed anything — a tap that submitted the
value that was already there. Both now keep the loaded value as a baseline in
state and compare the field against it, so one character's difference is what
arms the button and typing the original back in disarms it. Nodes 9553:113166
and 9553:113168.
The seeding flows also lacked distinctUntilChanged, so any unrelated emission
from the profile re-seeded the field and overwrote in-progress typing.
Leaving a step throws the edit away. The back icon dispatches DiscardChanges,
which puts the baseline back in the field; a gesture back reaches the same
outcome because each step's ViewModel is scoped to its nav entry and goes with
the pop. The photo step needed more than that: an abandoned pick left a
re-encoded file in the cache with nothing to delete it, so onCleared drops it,
covering the gesture back and the successful upload alike.
* feat(user-profile): open the photo step on the current avatar
The Set Profile Picture step opened on an empty well with a "+", so an account
that already has a picture looked like it had none. It now seeds from the stored
profile picture and falls back to it when a pick is discarded.
The seeded value is a server-side MediaItem, never a local Uri, so it cannot be
mistaken for a pick: Save stays disabled until one is made. That gate moves into
State.isChanged, matching the name and username steps.
Also stops the name and username fields being clobbered mid-edit. Both seeded the
field on every profile emission, and the 60s poll publishes UserProfile.Empty when
it cannot find the server profile — a different value, so distinctUntilChanged let
it through and it overwrote whatever was being typed. The field now follows the
store only while it is untouched; the baseline still moves either way, so the
confirm button stays honest.
Copy file name to clipboardExpand all lines: apps/flipcash/features/user-profile/src/main/kotlin/com/flipcash/app/userprofile/internal/name/NameEntryScreen.kt
+5-1Lines changed: 5 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -62,6 +62,10 @@ internal fun NameEntryScreen(
62
62
AppBarWithTitle(
63
63
onBackIconClicked = {
64
64
keyboard.hideIfVisible {
65
+
// Leaving throws the edit away rather than carrying it back in. A gesture
66
+
// back lands in the same place by a different route: the step's ViewModel
67
+
// is scoped to its nav entry, so popping the entry drops the field with it.
Copy file name to clipboardExpand all lines: apps/flipcash/features/user-profile/src/main/kotlin/com/flipcash/app/userprofile/internal/name/NameEntryViewModel.kt
Copy file name to clipboardExpand all lines: apps/flipcash/features/user-profile/src/main/kotlin/com/flipcash/app/userprofile/internal/photo/PhotoSelectionScreen.kt
Copy file name to clipboardExpand all lines: apps/flipcash/features/user-profile/src/main/kotlin/com/flipcash/app/userprofile/internal/photo/PhotoSelectionViewModel.kt
Copy file name to clipboardExpand all lines: apps/flipcash/features/user-profile/src/main/kotlin/com/flipcash/app/userprofile/internal/username/UsernameEntryScreen.kt
+5-1Lines changed: 5 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -58,6 +58,10 @@ internal fun UsernameEntryScreen() {
58
58
AppBarWithTitle(
59
59
onBackIconClicked = {
60
60
keyboard.hideIfVisible {
61
+
// Leaving throws the edit away rather than carrying it back in. A gesture back
62
+
// lands in the same place by a different route: the step's ViewModel is scoped
63
+
// to its nav entry, so popping the entry drops the field with it.
0 commit comments