Skip to content

Commit

Permalink
fix: ensure async function finish before window closes
Browse files Browse the repository at this point in the history
  • Loading branch information
ACTCD committed Jan 30, 2024
1 parent 08ab4f7 commit b514e9b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
15 changes: 7 additions & 8 deletions src/ext/action-popup/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,11 @@
}
});
async function gotoExtensionPage() {
await openExtensionPage();
window.close();
}
/**
* Temporary settings page entrance for beta test (iOS)
* @todo new permanent button will be added via popup refactoring
Expand Down Expand Up @@ -524,7 +529,7 @@
{/if}
{#if showBetaNews && platform !== "macos"}
<div class="warn">
NEW: <button on:click={openExtensionPage}><b>Settings page</b></button> is
NEW: <button on:click={gotoExtensionPage}><b>Settings page</b></button> is
now available on iOS!
<IconButton
icon={iconClear}
Expand Down Expand Up @@ -594,13 +599,7 @@
</div>
{#if !inactive && platform === "macos"}
<div class="footer">
<button
class="link"
on:click={() => {
openExtensionPage();
window.close();
}}
>
<button class="link" on:click={gotoExtensionPage}>
Open Extension Page
</button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/ext/shared/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,8 @@ export async function openExtensionPage() {
const tabs = await browser.tabs.query({ url });
const tab = tabs.find((e) => e.url.startsWith(url));
if (!tab) return browser.tabs.create({ url });
browser.tabs.update(tab.id, { active: true });
browser.windows.update(tab.windowId, { focused: true });
await browser.tabs.update(tab.id, { active: true });
await browser.windows.update(tab.windowId, { focused: true });
}

/**
Expand Down

0 comments on commit b514e9b

Please sign in to comment.