fix(communities): always show Save on the edit screen
The edit/create top bar was keyed on model.isEditing(), which reads existingDTag set by loadFrom(). loadFrom runs in a LaunchedEffect after the first composition, so the first render of the edit screen briefly showed the "Create" button before flipping to "Save". Derive the top bar from the `editing: Address?` parameter instead — it is known synchronously at composition, so edit mode shows "Save" on frame one.
This commit is contained in:
+6
-3
@@ -150,9 +150,12 @@ private fun CommunityFormScreen(
|
|||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
val titleRes =
|
// Derive the top bar from the parameter, not model.isEditing(), so the
|
||||||
if (model.isEditing()) R.string.edit_community else R.string.new_community
|
// first composition of the edit screen already shows "Save" before
|
||||||
if (model.isEditing()) {
|
// loadFrom() runs in its LaunchedEffect.
|
||||||
|
val isEditing = editing != null
|
||||||
|
val titleRes = if (isEditing) R.string.edit_community else R.string.new_community
|
||||||
|
if (isEditing) {
|
||||||
ActionTopBar(
|
ActionTopBar(
|
||||||
titleRes = titleRes,
|
titleRes = titleRes,
|
||||||
postRes = R.string.save,
|
postRes = R.string.save,
|
||||||
|
|||||||
Reference in New Issue
Block a user