Skip to content

More consistent logic for showing/hiding the NBBD prompt - #9320

Merged
outofambit merged 17 commits into
developmentfrom
fix-prompt-for-update-branch-2
Apr 7, 2020
Merged

outofambit merged 17 commits into
developmentfrom
fix-prompt-for-update-branch-2

Conversation

@rafeca

@rafeca rafeca commented Mar 19, 2020 •

Copy link
Copy Markdown
Contributor

Partially addresses #5293

This branch is based on #9319

Description

This PR partially addresses #6875 by fixing the point 2. stated in #6875 (comment) .

In order to fix this, I've decided to add a third flag that controls whether the user has currently dismissed the banner (this way if the user dismisses the banner, it doesn't get shown again when the diverging logic gets executed afterwards).

In terms of behaviour, I've tried to follow what was stated in the original NBBD issue. This is a quick summary:

  • The blue nudge is shown whenever when the number of commits behind is different from the last time Desktop checked, and it gets hidden when the user clicks on the history tab.
  • The prompt is shown whenever the current branch is behind the inferred branch. It stays visible until the user dismisses the prompt by clicking on the "x" button.

Something important to note is that this whole logic gets reset every time the user changes branches (or the app gets restarted). This means that if the user checks out a branch and goes back to the current branch, they'll see the blue nudge and the prompt again even if they have dismissed the prompt.

This is caused by the way the NBBD flags are stored, we could probably persist them in a different place to keep the state for longer.

cc/ @billygriffin, @nerdneha , @ampinsk

Screenshots

Before:

before

After:

after-2

Release notes

Notes: no-notes

Comment thread app/src/lib/app-state.ts
Comment on lines +698 to +707
export interface IDivergingBranchBannerState {
/** Show the diverging notification banner */
readonly isPromptVisible: boolean

/** Has the user dismissed the notification banner? */
readonly isPromptDismissed: boolean

/** Show the diverging notification nudge on the tab */
readonly isNudgeVisible: boolean
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've decided two put these 3 flags under the same object rather than having 3 separate flags starting with divergingBranchBannerXXXX. This also makes it slightly easier to update the state from the app-store.


public _setDivergingBranchBannerVisibility(
/** This shouldn't be called directly. See `Dispatcher`. */
public _updateDivergingBranchBannerState(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This method now can update any of the 3 NBBD flags by passing an object with the flags to update. This reduces some repetition and makes sure that only 1 update is emitted when changing multiple flags at once.

The main tradeoff is that the method is a bit more "dynamic" in the sense that it accepts a Partial of an interface as an argument (still, everything is still correctly covered by TypeScript).

@tierninho
tierninho self-requested a review March 19, 2020 21:22
tierninho
tierninho previously approved these changes Mar 19, 2020

@tierninho tierninho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ran through some tests and overall it looks good.

I noticed that the blue nudge is still present even when the user dismisses the prompt and even when the user navigates away to the Changes tab. Only until the user returns to the History tab does it disappear. This is more of a nit-pick and I'll leave it to you to decide to change it.

Screen Shot 2020-03-19 at 11 21 35 AM

@outofambit
outofambit self-requested a review March 20, 2020 15:38
@rafeca rafeca linked an issue Mar 25, 2020 that may be closed by this pull request
@rafeca
rafeca dismissed tierninho’s stale review March 26, 2020 13:52

The base branch was changed.

@rafeca
rafeca changed the base branch from fix-prompt-for-update-branch to development March 26, 2020 13:52
@rafeca

rafeca commented Mar 26, 2020

Copy link
Copy Markdown
Contributor Author

I just changed the base branch of this PR to be development, since #9319 has already been merged

@rafeca

rafeca commented Mar 27, 2020

Copy link
Copy Markdown
Contributor Author

@outofambit I checked with @ampinsk and the PR looks good to her! ✨

@Hopham641994 Hopham641994 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good

@outofambit outofambit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

one suggestion, otherwise this is great! excited to see it on beta!

Comment thread app/src/lib/stores/app-store.ts Resolved
@rafeca
rafeca requested a review from outofambit April 7, 2020 08:35
@outofambit
outofambit merged commit ea50bb2 into development Apr 7, 2020
@outofambit
outofambit deleted the fix-prompt-for-update-branch-2 branch April 7, 2020 21:53
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.

4 participants