Page MenuHomePhabricator

D14696.diff
No OneTemporary

D14696.diff

diff --git a/cashtab/extension/src/service_worker.js b/cashtab/extension/src/service_worker.js
--- a/cashtab/extension/src/service_worker.js
+++ b/cashtab/extension/src/service_worker.js
@@ -2,6 +2,8 @@
const NOTIFICATION_HEIGHT = 600;
const NOTIFICATION_WIDTH = 400;
+const EXTENSION_DEV_ID = 'aleabaopoakgpbijdnicepefdiglggfl';
+const EXTENSION_PROD_ID = 'obldfcmebhllhjlhjbnghaipekcppeag';
// This starts listening to the port created with `extension.runtime.connect` in contentscript.js
extension.runtime.onConnect.addListener(function (port) {
@@ -154,7 +156,27 @@
});
}
+function isCashtabWindow(window) {
+ return (
+ window &&
+ window.tabs &&
+ window.tabs.length === 1 &&
+ window.height === NOTIFICATION_HEIGHT &&
+ window.width === NOTIFICATION_WIDTH &&
+ (window.tabs[0].url.includes(EXTENSION_DEV_ID) ||
+ window.tabs[0].url.includes(EXTENSION_PROD_ID))
+ );
+}
+
async function openWindow(options) {
+ // Close existing windows before opening a new window
+ const windows = await extension.windows.getAll({ populate: true });
+ for (let window of windows) {
+ if (isCashtabWindow(window)) {
+ await extension.windows.remove(window.id);
+ }
+ }
+
return new Promise((resolve, reject) => {
extension.windows.create(options, newWindow => {
const error = checkForError();

File Metadata

Mime Type
text/plain
Expires
Tue, May 20, 21:39 (17 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5865986
Default Alt Text
D14696.diff (1 KB)

Event Timeline