Add a communication channel for forcing reloads across tab sessions.

Review Request #13048 — Created May 16, 2023 and submitted — Latest diff uploaded

Information

Review Board
release-6.x

Reviewers

The new behavior for the unified banner means that individual tabs fetch
and keep track of pending review/draft IDs more eagerly than before. The
result of this is that it was easier to hit bugs when performing actions
with a review request open in multiple tabs.

This change adds a small utility that makes use of the
BroadcastChannel API to coordinate across multiple tabs/windows within
a browser session. Right now the only message that we send is "reload",
which asks other tabs to reload their contents. This is sent when
something is either published or discarded, which invalidates draft IDs.

The broadcast channel is origin-wide, so each PageView can implement a
method to return a data blob that's used for filtering whether or not to
reload. The default implementation is empty, and ReviewablePageView
will filter based on the review request ID (so any open tabs related to
that review request will be triggered).

  • Ran js-tests.
  • Published review requests, reviews, and replies from one tab, and saw
    other tabs pop up the alert and reload.
  • Discarded drafts from the unified banner and from the review dialog,
    and saw other tabs pop up the alert and reload.

Diff Revision 1

This is not the most recent revision of the diff. The latest diff is revision 3. See what's changed.

orig
1
2
3

Commits

First Last Summary ID Author
Add a communication channel for forcing reloads across tab sessions.
The new behavior for the unified banner means that individual tabs fetch and keep track of pending review/draft IDs more eagerly than before. The result of this is that it was easier to hit bugs when performing actions with a review request open in multiple tabs. This change adds a small utility that makes use of the `BroadcastChannel` API to coordinate across multiple tabs/windows within a browser session. Right now the only message that we send is "reload", which asks other tabs to reload their contents. This is sent when something is either published or discarded, which invalidates draft IDs. Testing Done: - Published review requests, reviews, and replies from one tab, and saw other tabs pop up the alert and reload. - Discarded drafts from the unified banner and from the review dialog, and saw other tabs pop up the alert and reload.
7df4b2f0db096ec892c1599ea37ce66517ca5cb6 David Trowbridge
reviewboard/static/rb/js/common/index.ts
reviewboard/static/rb/js/common/models/commChannel.ts
reviewboard/static/rb/js/common/views/pageView.ts
reviewboard/static/rb/js/reviews/views/unifiedBannerView.ts
reviewboard/static/rb/js/views/reviewDialogView.es6.js
Loading...