mirror of
https://github.com/tubearchivist/browser-extension.git
synced 2026-03-23 20:37:07 +00:00
[PR #18] [MERGED] Refactor message passing and surface errors to users #46
Labels
No labels
bug
bug
duplicate
enhancement
help wanted
invalid
not an issue
not an issue
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
tubearchivist/archived-browser-extension#46
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/tubearchivist/browser-extension/pull/18
Author: @bakkot
Created: 2/12/2023
Status: ✅ Merged
Merged: 2/20/2023
Merged by: @bbilly1
Base:
master← Head:refactor📝 Commits (5)
fbf1db6refactor message passing between popup/background16a52bfsurface errors to user in popup.jsce827efmove logic into background.js5a59c4csplit youtube messageebb9247handle errors from URL constructor📊 Changes
5 files changed (+143 additions, -78 deletions)
View changed files
📝
extension/background.js(+76 -47)📝
extension/index.html(+1 -0)📝
extension/popup.js(+49 -22)📝
extension/script.js(+12 -8)📝
extension/style.css(+5 -1)📄 Description
This cleans up the logic for passing messages between
popup.js/script.jsandbackground.js, so that instead of determining the kind of message based on which properties the message object has, there is an explicittypeproperty. This is more traditional and, in my experience, much easier to maintain and reason about. Plus it means that if you get a message you don't recognize it's easy to throw an appropriate error.Also, it wraps up the message-passing logic so that errors in
background.jspropagate to the script which passed the message, and surfaces those errors in the popup. (Previously errors weren't being handled at all; in Firefox that would eventually trigger an error in the popup, when thesendMessagehandler was garbage collected, but in Chrome that failure was completely silent.)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.