From b514e9b5e5daad4c93ebc5fea384501439d9a91a Mon Sep 17 00:00:00 2001
From: ACTCD <101378590+ACTCD@users.noreply.github.com>
Date: Tue, 30 Jan 2024 18:24:19 +0800
Subject: [PATCH 1/2] fix: ensure async function finish before window closes
---
src/ext/action-popup/App.svelte | 15 +++++++--------
src/ext/shared/utils.js | 4 ++--
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/ext/action-popup/App.svelte b/src/ext/action-popup/App.svelte
index 511bd6fd..09bfe195 100644
--- a/src/ext/action-popup/App.svelte
+++ b/src/ext/action-popup/App.svelte
@@ -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
@@ -524,7 +529,7 @@
{/if}
{#if showBetaNews && platform !== "macos"}
- NEW: is
+ NEW: is
now available on iOS!
{#if !inactive && platform === "macos"}
diff --git a/src/ext/shared/utils.js b/src/ext/shared/utils.js
index 8f82fc96..208030e5 100644
--- a/src/ext/shared/utils.js
+++ b/src/ext/shared/utils.js
@@ -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 });
}
/**
From 46912670d6f99e2cf6c5d6215ffc48f846c65a8e Mon Sep 17 00:00:00 2001
From: ACTCD <101378590+ACTCD@users.noreply.github.com>
Date: Tue, 30 Jan 2024 18:48:41 +0800
Subject: [PATCH 2/2] fix: ensure window focus transfer order
---
src/ext/background/main.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/ext/background/main.js b/src/ext/background/main.js
index 87b3cb5b..131ab431 100644
--- a/src/ext/background/main.js
+++ b/src/ext/background/main.js
@@ -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" });
}