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: Fix injection and pop window collision #474

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HandlerMethod } from '.';
import { InjectionMessage, InjectionMessageInstance } from './message';
import { existsPopups } from './methods';
import { existsPopups, removePopups } from './methods';
import { InjectCore } from './methods/core';

export class MessageHandler {
Expand Down Expand Up @@ -52,10 +52,7 @@ export class MessageHandler {
}
const isPopup = await existsPopups();
if (isPopup) {
sendResponse(
InjectionMessageInstance.failure('UNRESOLVED_TRANSACTION_EXISTS', {}, message.key),
);
return true;
await removePopups();
}
switch (message.type) {
case 'DO_CONTRACT':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ export const existsPopups = async (): Promise<boolean> => {
return windows.findIndex((window) => window.type === 'popup') > -1;
};

export const removePopups = async (): Promise<void> => {
const windows = await chrome.windows.getAll();
windows.forEach((window) => {
if (window.type === 'popup' && window.id) {
chrome.windows.remove(window.id);
}
});
};

export const checkEstablished = async (
requestData: InjectionMessage,
sendResponse: (response: any) => void,
Expand Down
Loading