Commit 0684ddc
fix(compose): lazy list keys, stale remember, redundant derivedStateOf (#851)
* fix(compose): prevent stale onConfirm capture in SlideToConfirm
onConfirm was captured by a LaunchedEffect(Unit) without
rememberUpdatedState. If the caller recomposes with a new lambda,
the stale version executes on swipe-to-confirm.
* fix(compose): cache collection transforms in per-item composables
Wrap sortedBy/groupBy, map, and forEachIndexed transforms in
remember(key) so they do not re-run on every recomposition inside
LazyColumn item factories.
* fix(compose): use collectAsStateWithLifecycle in CashScreenContent
Last remaining collectAsState() call in production code. Stops flow
collection when the app is backgrounded.
* fix(compose): use mutableLongStateOf to avoid autoboxing
Replace mutableStateOf(0L) with mutableLongStateOf(0L) to avoid
Long autoboxing on every state read.
* fix(compose): defer animation reads to draw phase via graphicsLayer
Replace Modifier.alpha(animatedFloat) and Modifier.rotate(animatedFloat)
with graphicsLayer equivalents so animated values are read in the draw
phase instead of triggering recomposition every frame.
* fix(compose): use viewModel as LaunchedEffect key for event flow collection
Replace LaunchedEffect(Unit) with LaunchedEffect(viewModel) so the
effect restarts if the ViewModel instance changes, and is consistent
across composables.
* fix(compose): add stable keys to lazy lists
Add key parameters to items() calls in DeviceLogsScreen, UserFlagsEditor,
FrequentlyUsedEmojis, and EmojiSearch so Compose can diff items correctly
during recomposition instead of recomposing every item.
* fix(compose): use rememberSaveable for user-driven UI flags
Replace remember with rememberSaveable for isExportSeedRequested and
isStoragePermissionGranted so these flags survive configuration changes.
* fix(compose): use staticCompositionLocalOf for singleton controllers
LocalAppUpdater and LocalCoinbaseOnRampController are provided once at
app startup and never change. Using staticCompositionLocalOf avoids
unnecessary recomposition tracking overhead.
* fix(compose): correct parameter ordering in shared components
Reorder parameters to follow Compose API guidelines: required params
first, then modifier, then optional params, then trailing lambdas.
Also fix modifier chain ordering in Pill and CodeToggleSwitch so the
caller modifier is applied outermost.
* fix(compose): add modifier parameter to ConnectionStatus
Shared reusable component was missing a modifier parameter, preventing
callers from controlling its layout.
* fix(compose): key BillCustomizationScreen effect on changing state
LaunchedEffect(Unit) was reading state.customizations and
state.purchaseAmount but only running once. Key on these values
so the effect re-fires when they change.
* refactor(compose): remove rememberedClickable/rememberedLongClickable wrappers
With Strong Skipping Mode enabled, the remember-based lambda caching in
rememberedClickable is redundant — Compose auto-stabilizes lambdas. The
Modifier.composed wrapper also allocates a sub-composition per element
per recomposition.
- Delete both rememberedClickable overloads from Modifier.kt
- Rename rememberedLongClickable to longClickable (no composed)
- Simplify noRippleClickable (no composed, null interactionSource)
- Keep unboundedClickable (needs composed for @composable ripple())
- Migrate 38 call sites across the codebase:
- Simple .rememberedClickable -> .clickable (standard foundation)
- No-ripple pattern -> .noRippleClickable
- Long click -> .longClickable
- Remove unused MutableInteractionSource imports
* fix(compose): add lazy list keys, fix stale remember, remove redundant derivedStateOf
- Add stable `key` to lazy list items in TokenDetails and BackgroundControls
- Remove redundant `derivedStateOf` wrappers where the block reads no
snapshot State (NavigationBar, TransactionReceipt, TokenList)
- Add missing `remember` keys to prevent stale cached values
(LabsScreen, TokenDiscoveryScreen, Editors)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 4f51f44 commit 0684ddc
8 files changed
Lines changed: 15 additions & 28 deletions
File tree
- apps/flipcash
- core/src/main/kotlin/com/flipcash/app/core/ui
- features
- bill-customization/src/main/kotlin/com/flipcash/app/bill/customization/features
- discovery/src/main/kotlin/com/flipcash/app/discovery
- lab/src/main/kotlin/com/flipcash/app/lab
- tokens/src/main/kotlin/com/flipcash/app/tokens/internal/components/info
- userflags/src/main/kotlin/com/flipcash/app/userflags/internal/components
- withdrawal/src/main/kotlin/com/flipcash/app/withdrawal/internal/components
Lines changed: 1 addition & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | 23 | | |
26 | 24 | | |
27 | 25 | | |
| |||
112 | 110 | | |
113 | 111 | | |
114 | 112 | | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | 113 | | |
119 | | - | |
| 114 | + | |
120 | 115 | | |
121 | 116 | | |
122 | 117 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| |||
Lines changed: 2 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | 13 | | |
16 | 14 | | |
17 | 15 | | |
| |||
68 | 66 | | |
69 | 67 | | |
70 | 68 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 69 | + | |
| 70 | + | |
75 | 71 | | |
76 | 72 | | |
77 | 73 | | |
| |||
Lines changed: 5 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 60 | + | |
| 61 | + | |
64 | 62 | | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
70 | 66 | | |
71 | 67 | | |
72 | 68 | | |
| |||
0 commit comments