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(
|
||||
topBar = {
|
||||
val titleRes =
|
||||
if (model.isEditing()) R.string.edit_community else R.string.new_community
|
||||
if (model.isEditing()) {
|
||||
// Derive the top bar from the parameter, not model.isEditing(), so the
|
||||
// first composition of the edit screen already shows "Save" before
|
||||
// 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(
|
||||
titleRes = titleRes,
|
||||
postRes = R.string.save,
|
||||
|
||||
Reference in New Issue
Block a user