Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14864696
D14696.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D14696.diff
View Options
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
Details
Attached
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)
Attached To
D14696: [Cashtab Extension] Close open pop-ups before opening a new one
Event Timeline
Log In to Comment