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
base: master
Are you sure you want to change the base?
Conversation
true | ||
} else { | ||
val hasParent = tab is TabSessionState && tab.parentId != null | ||
removeTabUseCase(tab.id, selectParentIfExists = hasParent) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this 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.
Pull Request checklist