-
Notifications
You must be signed in to change notification settings - Fork 29
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
fix check for message listeners #1436
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,6 @@ import { | |
migrateSorobanRpcUrlNetworkDetails, | ||
versionedMigration, | ||
} from "./helpers/dataStorage"; | ||
import { isExternalMessage, isResponse } from "./helpers/message"; | ||
|
||
export const initContentScriptMessageListener = () => { | ||
browser?.runtime?.onMessage?.addListener((message) => { | ||
|
@@ -36,16 +35,22 @@ export const initExtensionMessageListener = () => { | |
// todo this is kinda ugly | ||
const req = request as ExternalRequest | Response; | ||
let res; | ||
if (isResponse(req) && Object.values(SERVICE_TYPES).includes(req.type)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the isResponse vs isExternalMessage checks didn't quite work because they were keying off of Unfortunately this meant requests that were coming from the extension itself weren't making it to the appropriate handler. The type casting is a little ugly, but accomplishes routing the requests to the appropriate handler. The comment |
||
|
||
if (Object.values(SERVICE_TYPES).includes(req.type as SERVICE_TYPES)) { | ||
// eslint-disable-next-line | ||
res = await popupMessageListener(req, sessionStore); | ||
res = await popupMessageListener(req as Response, sessionStore); | ||
} | ||
if ( | ||
isExternalMessage(req) && | ||
Object.values(EXTERNAL_SERVICE_TYPES).includes(req.type) | ||
Object.values(EXTERNAL_SERVICE_TYPES).includes( | ||
req.type as EXTERNAL_SERVICE_TYPES, | ||
) | ||
) { | ||
// eslint-disable-next-line | ||
res = await freighterApiMessageListener(req, sender, sessionStore); | ||
res = await freighterApiMessageListener( | ||
req as ExternalRequest, | ||
sender, | ||
sessionStore, | ||
); | ||
} | ||
|
||
return res; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noticed this issue with migrations, so adding the fix while i'm here