Skip to content

Commit

Permalink
Merge pull request #616 from quoid/issue/614
Browse files Browse the repository at this point in the history
fix: make the `Open Extension Page` button work stably
  • Loading branch information
ACTCD authored Jan 31, 2024
2 parents fc99e1e + 4691267 commit c51a6cb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 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/background/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,10 +496,10 @@ browser.webNavigation.onCompleted.addListener(setBadgeCount);

// handle native app messages
const port = connectNative();
port.onMessage.addListener((message) => {
port.onMessage.addListener(async (message) => {
// console.info(message); // DEBUG
if (message.name === "SAVE_LOCATION_CHANGED") {
openExtensionPage();
await openExtensionPage();
if (message?.userInfo?.returnApp === true) {
sendNativeMessage({ name: "OPEN_APP" });
}
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 c51a6cb

Please sign in to comment.