Communicate store refresh and item moves across tabs #10905
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is something I've been thinking about for a while - it turned out not to be too hard. For folks who open DIM in multiple tabs, the experience can kind of suck, because each tab is its own independent instance. This means they can each load their own view of the profile, and any item moves are only reflected in the tab they're done in.
This PR uses the Web Locks API and BroadcastChannel to sync up multiple tabs. Now, only one tab will refresh the inventory at any given time. When it's done, it notifies all the other tabs to refresh the cached profile from Bungie.net.
I also made it notify about item moves - you can open two windows side by side, and start moving items in one window, those moves will be replicated in the other tab.
It should be pretty easy to expand this to other actions - lock/unlock, DIM API storage (tagging, loadout updates), clearing the "new item" flag.