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

Close #170 - Go to parent tab if one exists on back press #2338

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jonalmeida
Copy link
Collaborator

Pull Request checklist

@jonalmeida jonalmeida added the 🕵️‍♀️ needs review PRs that need to be reviewed label May 19, 2023
@jonalmeida jonalmeida requested a review from a team as a code owner May 19, 2023 03:41
true
} else {
val hasParent = tab is TabSessionState && tab.parentId != null
removeTabUseCase(tab.id, selectParentIfExists = hasParent)
Copy link
Contributor

Choose a reason for hiding this comment

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

❓ Mostly for my understanding, I was checking the RemoveTabUsecase (reducer), it seems the tab.parentId != null check is done there, so do we need to pass hasParent as the second param or just true would suffice.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, we don't have to do the extra check for the parentId. When this code was originally written, the use case was not doing this check, so we don't need the refactor to include it as well.

Since we're also not in the SessionState.Source.External case, then the tab is TabSessionState is also redundant as we're not a CustomTabSessionState then.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since we're also not in the SessionState.Source.External case, then the tab is TabSessionState is also redundant as we're not a CustomTabSessionState then.

CustomTabSessionState could still have source as SessionState.Source.Internal.CustomTab right? So just the case that the source is not external is not proof enough that the tab is TabSessionState right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Interesting point! If a custom tab is internal then we probably do want to finish the activity too because we would be in a context of a separate activity (external app activity).

The secondary value of the tab is TabSessionState && tab.parentId != null check is for the return value to tell our other features that we've handled the back press in this feature.

So maybe the if-statement above should be:

val isExternalOrCustomTab = tab.source is SessionState.Source.External ||
    tab.source is SessionState.Source.Internal.CustomTab

return if (isExternalOrCustomTab && !tab.restored) {
    activity.finish()
    removeTabUseCase(tab.id)
    true
} else {
    val hasParent = tab is TabSessionState && tab.parentId != null
    removeTabUseCase(tab.id, selectParentIfExists = hasParent) // Alternatively, set this to always true.
    // We want to return to home if this session didn't have a parent session to select.
    hasParent
}

What do you think?

Copy link
Contributor

@rahulsainani rahulsainani left a comment

Choose a reason for hiding this comment

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

Looks good and works well! 🚀 Had one question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🕵️‍♀️ needs review PRs that need to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants