Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix double back navigation in roles and permissions screen #2506

Conversation

jmartinesp
Copy link
Contributor

@jmartinesp jmartinesp commented Mar 7, 2024

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Change use of SideEffect for LaunchedEffect, which prevents the action from being called twice when recomposing.

Motivation and context

After saving changes in the 'edit admins' or 'edit moderators' screens, tapping the back navigation arrow went back twice.

Tests

  • Go to a role where you're an admin, select 'roles and permissions' in its settings.
  • Select the 'Moderators' item.
  • Toggle the moderator role permissions in some user, save the changes.
  • Tap on the back arrow icon in the top app bar. If it only goes back once, it's fixed.

Tested devices

  • Physical
  • Emulator
  • OS version(s): 14

Checklist

This happened after saving changes and pressing the back navigation button in the top app bar.
@jmartinesp jmartinesp requested a review from a team as a code owner March 7, 2024 12:36
@jmartinesp jmartinesp requested review from bmarty and removed request for a team March 7, 2024 12:36
Copy link
Contributor

github-actions bot commented Mar 7, 2024

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/gLfrZF

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I propose an alternative fix, but your proposal is OK!

The screenshot test are not passing, did not check yet what is failing. EDIT: I guess updating the branch should fix it. I do it.

@@ -189,7 +188,7 @@ fun ChangeRolesView(
)
}
is AsyncAction.Success -> {
SideEffect { updatedOnBackPressed() }
LaunchedEffect(action) { updatedOnBackPressed() }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another possible fix is to use AsyncActionView:

        AsyncActionView(
            async = state.exitState,
            onSuccess = { updatedOnBackPressed() },
            confirmationDialog = {
                ConfirmationDialog(
                    title = stringResource(CommonStrings.dialog_unsaved_changes_title),
                    content = stringResource(CommonStrings.dialog_unsaved_changes_description_android),
                    onSubmitClicked = { state.eventSink(ChangeRolesEvent.Exit) },
                    onDismiss = { state.eventSink(ChangeRolesEvent.CancelExit) }
                )
            },
            onErrorDismiss = { /* Cannot happen */ },
        )

Copy link
Contributor Author

@jmartinesp jmartinesp Mar 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh true, it's the perfect place to use it. Thanks!

Done in 3037b77

Copy link

codecov bot commented Mar 7, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 72.97%. Comparing base (410954e) to head (3037b77).
Report is 12 commits behind head on develop.

Files Patch % Lines
...rolesandpermissions/changeroles/ChangeRolesView.kt 80.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2506      +/-   ##
===========================================
- Coverage    72.97%   72.97%   -0.01%     
===========================================
  Files         1394     1394              
  Lines        33511    33512       +1     
  Branches      6493     6492       -1     
===========================================
  Hits         24455    24455              
- Misses        5671     5672       +1     
  Partials      3385     3385              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jmartinesp jmartinesp added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Mar 7, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label Mar 7, 2024
Copy link

sonarcloud bot commented Mar 7, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@jmartinesp jmartinesp merged commit 878a36f into develop Mar 7, 2024
18 of 19 checks passed
@jmartinesp jmartinesp deleted the fix/jme/double-back-navigation-after-saving-roles-and-permission-changes branch March 7, 2024 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants