Skip to content

Commit

Permalink
fix: bind listener context
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalygashkov committed Jan 6, 2025
1 parent c841ae9 commit b0f7f4b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/extension/entrypoints/eme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,19 @@ export default defineUnlistedScript(() => {
console.log(`Message: ${session.messages?.get(messageType)}`);
console.groupEnd();

if (['license-release', 'license-renewal'].includes(messageType)) return;
if (['license-release', 'license-renewal'].includes(messageType)) {
return;
}

const response = await send({
action: messageType,
initData: session.initData,
initDataType: session.initDataType,
message: session.messages?.get(messageType),
});
if (!response) return null;
if (!response) {
return;
}

const challenge = base64.parse(response);

Expand Down Expand Up @@ -262,7 +267,9 @@ export default defineUnlistedScript(() => {
) => {
const modifiedEvent = await onMessage(event);
const isFn = (fn: unknown) => typeof fn === 'function';
const handler = isFn(listener) ? listener : listener.handleEvent;
const handler = isFn(listener)
? listener
: listener.handleEvent.bind(listener);
return handler(modifiedEvent || event);
};
return _target.apply(_this, [type, listenerWrapper, useCapture]);
Expand Down

0 comments on commit b0f7f4b

Please sign in to comment.