Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Prevent firing updatePinnedTabs repeatedly for the same state/window combination #11862

Merged
merged 1 commit into from
Dec 24, 2017

Conversation

petemill
Copy link
Member

@petemill petemill commented Nov 9, 2017

Fix #11861 (and #12377)

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).
  • Tagged reviewers and labelled the pull request as needed.

Test Plan:

Steps to Reproduce

  1. Open window1
  2. Open window2
  3. Open a tab in window1
  4. Pin a tab in window1

This can then cause some weird errors when a window's tab state is out of sync with what it should have.

Expected result:

  • The tab is pinned once in window2 and once in window1

Previous actual result:

  • The tab is pinned twice in window2 and once in window1

Reviewer Checklist:

Tests

  • Adequate test coverage exists to prevent regressions
  • Tests should be independent and work correctly when run individually or as a suite ref
  • New files have MPL2 license header

@petemill petemill added this to the Triage Backlog milestone Nov 9, 2017
@petemill petemill self-assigned this Nov 9, 2017
@petemill petemill requested a review from bsclifton November 9, 2017 00:27
@@ -72,19 +75,26 @@ const siteMatchesTab = (site, tab) => {
return matchesLocation && matchesPartition
}

const updatePinnedTabs = (win) => {
const updatePinnedTabs = (win, appState) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure why we are passing state in, which we get in the same way as we did before?

Copy link
Member Author

Choose a reason for hiding this comment

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

Seems like a better practice and more consistent with the way other functions are structured. Plus it avoids calling AppStore.getstate multiple times in a row for multiple windows (though yes I know it is a very cheap function) and it feels cleaner and easier to test. Plus I’m not sure at all why the function had the AppStore require inside the function before...?? Was it to stop the module from being evaluated in case it wasn’t ever required in the process (I can’t imagine that happening)

@petemill petemill modified the milestones: Triage Backlog, 0.21.x (Developer Channel) Dec 23, 2017
@petemill petemill force-pushed the fix-pinned-tabs-repeating branch from 9e1716d to 67024e3 Compare December 23, 2017 01:48
@petemill petemill modified the milestones: 0.21.x (Developer Channel), 0.20.x (Beta Channel) Dec 23, 2017
// cache that this state has been updated for this window,
// so we do not repeat the operation until
// this specific part of the state has changed
// See
Copy link
Member

Choose a reason for hiding this comment

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

looks like your comment just drops off here 😛

…combination

Use WeakMap so that we lose the reference to an old state when we lose the reference to an old window

Fix brave#11861
@bsclifton bsclifton force-pushed the fix-pinned-tabs-repeating branch from 67024e3 to dfd3d54 Compare December 24, 2017 05:50
Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

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

Changes look good! 👍 Verified it works as expected- GJ with the test too

@bsclifton bsclifton merged commit 5d78c1c into brave:master Dec 24, 2017
bsclifton added a commit that referenced this pull request Dec 24, 2017
Prevent firing updatePinnedTabs repeatedly for the same state/window combination
bsclifton added a commit that referenced this pull request Dec 24, 2017
Prevent firing updatePinnedTabs repeatedly for the same state/window combination
@bsclifton
Copy link
Member

master 5d78c1c
0.21.x 83958ed
0.20.x a718cb8

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants