-
Notifications
You must be signed in to change notification settings - Fork 970
Prevent firing updatePinnedTabs repeatedly for the same state/window combination #11862
Conversation
@@ -72,19 +75,26 @@ const siteMatchesTab = (site, tab) => { | |||
return matchesLocation && matchesPartition | |||
} | |||
|
|||
const updatePinnedTabs = (win) => { | |||
const updatePinnedTabs = (win, appState) => { |
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.
not sure why we are passing state in, which we get in the same way as we did before?
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.
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)
9e1716d
to
67024e3
Compare
// 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 |
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 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
67024e3
to
dfd3d54
Compare
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.
Changes look good! 👍 Verified it works as expected- GJ with the test too
Prevent firing updatePinnedTabs repeatedly for the same state/window combination
Prevent firing updatePinnedTabs repeatedly for the same state/window combination
Fix #11861 (and #12377)
Submitter Checklist:
git rebase -i
to squash commits (if needed).Test Plan:
Steps to Reproduce
This can then cause some weird errors when a window's tab state is out of sync with what it should have.
Expected result:
Previous actual result:
Reviewer Checklist:
Tests