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

Prevent duplicate navigate up #6347

Conversation

Rawa
Copy link
Contributor

@Rawa Rawa commented Jun 13, 2024

Makes use of newly added dropUnlessResumed to prevent user from clicking navigate up while we already are navigating up.


This change is Reviewable

Copy link

linear bot commented Jun 13, 2024

@Rawa Rawa self-assigned this Jun 13, 2024
@Rawa Rawa added the Android Issues related to Android label Jun 13, 2024
@Rawa Rawa force-pushed the service-killed-if-user-navigates-up-twice-quickly-from-droid-963 branch from fd88980 to ca19e63 Compare June 13, 2024 11:36
Copy link
Collaborator

@albin-mullvad albin-mullvad left a comment

Choose a reason for hiding this comment

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

Reviewed 14 of 15 files at r1, all commit messages.
Reviewable status: 14 of 15 files reviewed, 3 unresolved discussions (waiting on @Rawa)

a discussion (no related file):
Is there any way we can ensure we don't miss adding dropUnlessResumed?



android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/WireguardCustomPortDialog.kt line 19 at r1 (raw file):

import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.lifecycle.compose.dropUnlessResumed

Used in this class? Maybe reviewable acting up

Code quote:

dropUnlessResumed

android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreen.kt line 156 at r1 (raw file):

    LaunchedEffectCollect(vm.uiSideEffect) {
        when (it) {
            SelectLocationSideEffect.CloseScreen -> navigateBack()

Why was this specific call broken broken out? 🤔

Code quote:

navigateBack()

@Rawa Rawa force-pushed the service-killed-if-user-navigates-up-twice-quickly-from-droid-963 branch from 096e23a to aec7d8c Compare June 13, 2024 12:26
Copy link
Contributor Author

@Rawa Rawa left a comment

Choose a reason for hiding this comment

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

Reviewable status: 8 of 44 files reviewed, 3 unresolved discussions (waiting on @albin-mullvad)

a discussion (no related file):

Previously, albin-mullvad wrote…

Is there any way we can ensure we don't miss adding dropUnlessResumed?

Not straight of that I can think of I'm afraid :( It is also a bit of case by case where we need to apply it.

So things to worth noting in this PR:

  • dropUnlessResumed needs to be called in a composable context (thus we can't call it from within side-effects. unless we create the lambda outside)
  • dropUnlessResumed returns a lambda with return type () -> Unit does we can apply it do places where we pass an argument.

My approach for applying it:

  • We apply it everywhere it makes sense (especially crucial is the navigate up I feel)
  • For side effect we expect it do collect in a sane manner (e.g only if Resumed) or make us of onlyIfResume argument for navigate
  • I've removed launchSingleTopin a lot of places since it feels a bit duplicated, open for discussion to add this back if we feel like it adds something.


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreen.kt line 156 at r1 (raw file):

Previously, albin-mullvad wrote…

Why was this specific call broken broken out? 🤔

Removed, also see comment for main PR


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/WireguardCustomPortDialog.kt line 19 at r1 (raw file):

Previously, albin-mullvad wrote…

Used in this class? Maybe reviewable acting up

Fixed.

Copy link
Contributor

@Pururun Pururun left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 15 files at r1, 35 of 35 files at r4, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @albin-mullvad and @Rawa)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListsScreen.kt line 105 at r4 (raw file):

            navigator.navigate(
                EditCustomListDestination(customListId = customList.id),
                onlyIfResumed = true

This uses both launchSingleTop and onlyIfResumed which in this case mostly do the same?


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/DeviceRevokedScreen.kt line 68 at r4 (raw file):

        state = state,
        onSettingsClicked =
            dropUnlessResumed {

Same as above, both dropUnlessResumed and launchSingleTop


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/VpnSettingsScreen.kt line 39 at r4 (raw file):

import com.ramcosta.composedestinations.result.ResultRecipient
import kotlinx.coroutines.launch
import mullvad_daemon.management_interface.portRange

This should probably not be here?

@Rawa Rawa force-pushed the service-killed-if-user-navigates-up-twice-quickly-from-droid-963 branch from aec7d8c to 9f46d4c Compare June 14, 2024 05:59
Copy link
Contributor Author

@Rawa Rawa left a comment

Choose a reason for hiding this comment

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

Reviewable status: 9 of 44 files reviewed, 6 unresolved discussions (waiting on @albin-mullvad and @Pururun)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListsScreen.kt line 105 at r4 (raw file):

Previously, Pururun (Jonatan Rhodin) wrote…

This uses both launchSingleTop and onlyIfResumed which in this case mostly do the same?

Fixed.


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/DeviceRevokedScreen.kt line 68 at r4 (raw file):

Previously, Pururun (Jonatan Rhodin) wrote…

Same as above, both dropUnlessResumed and launchSingleTop

Thanks, fixed 👍


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/VpnSettingsScreen.kt line 39 at r4 (raw file):

Previously, Pururun (Jonatan Rhodin) wrote…

This should probably not be here?

Correct, mistake, fixed.

Copy link
Contributor

@Pururun Pururun left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 35 of 35 files at r6, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @albin-mullvad)

@Rawa Rawa requested a review from albin-mullvad June 14, 2024 07:42
@Rawa Rawa force-pushed the service-killed-if-user-navigates-up-twice-quickly-from-droid-963 branch from 9f46d4c to 01dc1bc Compare June 14, 2024 07:42
Copy link
Collaborator

@albin-mullvad albin-mullvad left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 35 files at r6, 2 of 2 files at r7, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

a discussion (no related file):

Previously, Rawa (David Göransson) wrote…

Not straight of that I can think of I'm afraid :( It is also a bit of case by case where we need to apply it.

So things to worth noting in this PR:

  • dropUnlessResumed needs to be called in a composable context (thus we can't call it from within side-effects. unless we create the lambda outside)
  • dropUnlessResumed returns a lambda with return type () -> Unit does we can apply it do places where we pass an argument.

My approach for applying it:

  • We apply it everywhere it makes sense (especially crucial is the navigate up I feel)
  • For side effect we expect it do collect in a sane manner (e.g only if Resumed) or make us of onlyIfResume argument for navigate
  • I've removed launchSingleTopin a lot of places since it feels a bit duplicated, open for discussion to add this back if we feel like it adds something.

Alright! Let's go with this approach for now 👍

But I really think that we long term should come up with a plan for making sure this is done correctly, either by using konsist or other types of test automation.


@Rawa Rawa force-pushed the service-killed-if-user-navigates-up-twice-quickly-from-droid-963 branch from 01dc1bc to fa999e7 Compare June 14, 2024 12:43
@albin-mullvad albin-mullvad force-pushed the service-killed-if-user-navigates-up-twice-quickly-from-droid-963 branch from fa999e7 to ad908ff Compare June 15, 2024 11:59
@albin-mullvad albin-mullvad requested a review from Pururun June 15, 2024 12:08
Copy link
Contributor

@Pururun Pururun left a comment

Choose a reason for hiding this comment

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

Reviewed 5 of 5 files at r8, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

Copy link
Contributor

@Pururun Pururun left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Rawa)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreen.kt line 211 at r8 (raw file):

                onlyIfResumed = true
            ) {
                launchSingleTop = true

Not needed to have both onlyIfResumed and launchSingleTop

@albin-mullvad albin-mullvad force-pushed the service-killed-if-user-navigates-up-twice-quickly-from-droid-963 branch from ad908ff to b043910 Compare June 17, 2024 09:00
@albin-mullvad albin-mullvad requested a review from Pururun June 17, 2024 09:02
Copy link
Collaborator

@albin-mullvad albin-mullvad left a comment

Choose a reason for hiding this comment

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

Reviewable status: 43 of 44 files reviewed, 1 unresolved discussion (waiting on @Pururun)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreen.kt line 211 at r8 (raw file):

Previously, Pururun (Jonatan Rhodin) wrote…

Not needed to have both onlyIfResumed and launchSingleTop

Nice find, fixed!

Copy link
Contributor

@Pururun Pururun left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 1 files at r9, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@albin-mullvad albin-mullvad force-pushed the service-killed-if-user-navigates-up-twice-quickly-from-droid-963 branch from b043910 to 8176188 Compare June 17, 2024 09:05
@albin-mullvad albin-mullvad merged commit 8eeefcb into main Jun 17, 2024
31 checks passed
@albin-mullvad albin-mullvad deleted the service-killed-if-user-navigates-up-twice-quickly-from-droid-963 branch June 17, 2024 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Issues related to Android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants