-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Project import generated by Copybara.
GitOrigin-RevId: 66a298014b079416c5e267d9d600bd279b7a2e32
- Loading branch information
Showing
4 changed files
with
26 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 24 additions & 12 deletions
36
examples/streaming-wallet-extension/src/common/streamingTabs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,27 @@ | ||
const URLS = [ | ||
"https://localhost:3000/demos/streaming", | ||
"http://192.168.86.248:3000/demos/streaming", | ||
"https://dev.dev.sparkinfra.net/demos/streaming", | ||
"https://app.lightspark.com/demos/streaming", | ||
]; | ||
|
||
export const findActiveStreamingDemoTabs = () => { | ||
return new Promise<chrome.tabs.Tab[]>((resolve) => { | ||
chrome.tabs.query( | ||
{ | ||
url: [ | ||
"https://localhost:3000/demos/streaming", | ||
"http://192.168.86.248:3000/demos/streaming", | ||
"https://dev.dev.sparkinfra.net/demos/streaming", | ||
"https://app.lightspark.com/demos/streaming", | ||
], | ||
}, | ||
(tabs) => resolve(tabs) | ||
); | ||
const allAndActive = Promise.all([ | ||
new Promise<chrome.tabs.Tab[]>((resolve) => { | ||
chrome.tabs.query({ url: URLS }, (tabs) => resolve(tabs)); | ||
}), | ||
new Promise<chrome.tabs.Tab[]>((resolve) => { | ||
chrome.tabs.query( | ||
{ url: URLS, active: true, lastFocusedWindow: true }, | ||
(tabs) => resolve(tabs) | ||
); | ||
}), | ||
]); | ||
return allAndActive.then(([all, active]) => { | ||
if (active.length > 0) { | ||
return active; | ||
} | ||
// Reverse the order so that the most recently opened tab is returned. | ||
return all.reverse(); | ||
}); | ||
}; |
Empty file.