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: make the Open Extension Page button work stably #616

Merged
merged 2 commits into from
Jan 31, 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
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
Loading