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

fix check for message listeners #1436

Merged
merged 2 commits into from
Aug 21, 2024
Merged

Conversation

piyalbasu
Copy link
Contributor

No description provided.

@@ -247,7 +247,7 @@ export const addIsNonSSLEnabled = async () => {

if (!storageVersion || semver.lt(storageVersion, "4.2.0")) {
await localStore.setItem(IS_NON_SSL_ENABLED_ID, false);
await migrateDataStorageVersion("4.2.0)");
await migrateDataStorageVersion("4.2.0");
Copy link
Contributor Author

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

@@ -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)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 messageId, which actually is only an optional field on the type Response. We only include it on requests that come through freighter-api and requests that come through localhost when you're in fullscreen mode in dev.

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 // todo this is kinda ugly definitely still stands. I'll take another shot at cleaning this up in the next release

@piyalbasu piyalbasu merged commit 2d5957e into release/5.23.1 Aug 21, 2024
3 checks passed
@piyalbasu piyalbasu deleted the bugfix/message-listener branch August 21, 2024 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants