Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Jul 17, 2024

Conversation

hainenber
Copy link
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>
// 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
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
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
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
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
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
34 checks passed
@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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change:frontend Requires changing the frontend dependencies:npm size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants