Skip to content

feat(frontend/hooks): replace 3rd-party BroadcastChannel with native Web API equivalence#29584

Merged
rusackas merged 3 commits into
apache:masterfrom
hainenber:use-native-broadcast-channel
Jul 17, 2024
Merged

feat(frontend/hooks): replace 3rd-party BroadcastChannel with native Web API equivalence#29584
rusackas merged 3 commits into
apache:masterfrom
hainenber:use-native-broadcast-channel

Conversation

@hainenber
Copy link
Copy Markdown
Contributor

feat(frontend/hooks): replace 3rd-party BroadcastChannel usage with native Web API equivalence

SUMMARY

Implementation of 2 years old TODO :D

Safari 15.4 was released 2 years ago (source) and so we can utilize its native Web API to replace a 3rd-party implementation.

Credit to Eric Wong's SO post for the implementation. I'm just a copy-paster after all :D

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TESTING INSTRUCTIONS

All CI checks should pass

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

…Web API equivalent

Signed-off-by: hainenber <dotronghai96@gmail.com>
@dosubot dosubot Bot added the change:frontend Requires changing the frontend label Jul 14, 2024
Comment thread superset-frontend/src/hooks/useTabId.ts Outdated
// After that, we should remove this dependency and use the native API.
const channel = new BroadcastChannel<TabIdChannelMessage>('tab_id_channel');
const channel: StrictBroadcastChannel<TabIdChannelMessage> =
new BroadcastChannel('tab_id_channel');
Copy link
Copy Markdown
Member

@justinpark justinpark Jul 16, 2024

Choose a reason for hiding this comment

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

nit: How about making the tab_id_channel value constant?

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.

done in HEAD :D

@rusackas
Copy link
Copy Markdown
Member

Thanks for tackling this! This looks like a great improvement, and long overdue!

Is there already (or should there be) a test making sure that messages are sent/received correctly?

Signed-off-by: hainenber <dotronghai96@gmail.com>
@hainenber
Copy link
Copy Markdown
Contributor Author

Unfortunately there's none but I can produce the expected result similar to what described in the original PR :D

State key is kept between reloads for a dashboard/chart opened in Explore tab. Would be sufficient?

Screen.Recording.2024-07-17.at.23.13.23.mov

Signed-off-by: hainenber <dotronghai96@gmail.com>
Copy link
Copy Markdown
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

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

It might be nice to have added test coverage, but this is an improvement over the current state of affairs for the product, and moves away from package complexities toward native browser, support, so I call it a win :)

@rusackas rusackas merged commit ae6e58f into apache:master Jul 17, 2024
@hainenber hainenber deleted the use-native-broadcast-channel branch July 18, 2024 01:32
eschutho pushed a commit that referenced this pull request Jul 24, 2024
…Web API equivalence (#29584)

Signed-off-by: hainenber <dotronghai96@gmail.com>
@github-actions github-actions Bot added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 4.1.0 First shipped in 4.1.0 labels Nov 14, 2024
qfcwell pushed a commit to qfcwell/superset that referenced this pull request May 12, 2026
…Web API equivalence (apache#29584)

Signed-off-by: hainenber <dotronghai96@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels change:frontend Requires changing the frontend dependencies:npm size/M 🚢 4.1.0 First shipped in 4.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants