Skip to content

Commit

Permalink
Merge pull request #14 from Holo-Host/hotfix/window-fix
Browse files Browse the repository at this point in the history
Fix window issue
  • Loading branch information
mrruby authored Jul 16, 2024
2 parents c9b0868 + bbadb37 commit dcdd72b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
36 changes: 14 additions & 22 deletions holo-key-manager-extension/scripts/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,41 +58,33 @@ const createWindowProperties = (parsedMessage?: MessageWithId): WindowProperties
left: 1100
});

const updateWindow = (
const createOrUpdateWindow = (
windowProperties: WindowProperties,
handleWindowUpdateOrCreate: () => Promise<void>
) =>
chrome.windows.update(
windowId!,
{ ...windowProperties, focused: true },
handleWindowUpdateOrCreate
);

const createWindow = (
windowProperties: WindowProperties,
handleWindowUpdateOrCreate: () => Promise<void>
) =>
chrome.windows.create(windowProperties, (newWindow) => {
) => {
const onWindowCreated = (newWindow: chrome.windows.Window | undefined) => {
if (!newWindow) return;
windowId = newWindow.id;
chrome.windows.onRemoved.addListener((id) => {
if (id === windowId) windowId = undefined;
});
handleWindowUpdateOrCreate();
});
};

const manageWindow = (
windowProperties: WindowProperties,
handleWindowUpdateOrCreate: () => Promise<void>
) =>
windowId
? updateWindow(windowProperties, handleWindowUpdateOrCreate)
: createWindow(windowProperties, handleWindowUpdateOrCreate);
if (windowId) {
chrome.windows.remove(windowId, () => {
windowId = undefined;
chrome.windows.create(windowProperties, onWindowCreated);
});
} else {
chrome.windows.create(windowProperties, onWindowCreated);
}
};

const updateOrCreateWindowCommon = (
handleWindowUpdateOrCreate: () => Promise<void>,
parsedMessage?: MessageWithId
) => manageWindow(createWindowProperties(parsedMessage), handleWindowUpdateOrCreate);
) => createOrUpdateWindow(createWindowProperties(parsedMessage), handleWindowUpdateOrCreate);

const updateOrCreateWindow = (
successAction: typeof NEEDS_SETUP,
Expand Down
2 changes: 1 addition & 1 deletion holo-key-manager-extension/static/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Holo key manager",
"description": "A browser extension to manage holo keys",
"version": "0.0.73",
"version": "0.0.74",
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiAtKvbHNTN3O2BLRZH7RkLczaMLenSeZu+YP+KomPQPZ18nt4DY9boIN/+GWts7gCzEeQq59l8edGdF2P7xAbsRxYR88+zFEbxMtIyfyqJZIlzXwnvPJkwGu/S6arNtX48K7q1+xnJEE7VyeYSj6/i2LR+LmPigCzY9JCP7+SmWVeYbdm3kZmReK0ecfh15RXSNjZpXJUgrbea/RVxweggYKnmhhOUBmuJSCLoWTXIuJPBMwGQK1O2GKBqHOq94bPVSF7j+4WzSpPan70ZZJX/reFsOFE/idfFN6wbizjR1Ne50Po03kudEmfQgoqUhVpd0wP8A3YbqE7ODdZcCPPwIDAQAB",
"manifest_version": 3,
"action": {
Expand Down

0 comments on commit dcdd72b

Please sign in to comment.