1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 07:43:35 +00:00

Added parameter and return types for tabsQueries in BrowserApi

This commit is contained in:
Daniel James Smith
2021-10-08 15:25:36 +02:00
parent 4fc968f682
commit d8bfb5a029

View File

@@ -11,27 +11,27 @@ export class BrowserApi {
static isFirefoxOnAndroid: boolean = navigator.userAgent.indexOf('Firefox/') !== -1 && static isFirefoxOnAndroid: boolean = navigator.userAgent.indexOf('Firefox/') !== -1 &&
navigator.userAgent.indexOf('Android') !== -1; navigator.userAgent.indexOf('Android') !== -1;
static async getTabFromCurrentWindowId(): Promise<any> { static async getTabFromCurrentWindowId(): Promise<chrome.tabs.Tab> | null {
return await BrowserApi.tabsQueryFirst({ return await BrowserApi.tabsQueryFirst({
active: true, active: true,
windowId: chrome.windows.WINDOW_ID_CURRENT, windowId: chrome.windows.WINDOW_ID_CURRENT,
}); });
} }
static async getTabFromCurrentWindow(): Promise<any> { static async getTabFromCurrentWindow(): Promise<chrome.tabs.Tab> | null {
return await BrowserApi.tabsQueryFirst({ return await BrowserApi.tabsQueryFirst({
active: true, active: true,
currentWindow: true, currentWindow: true,
}); });
} }
static async getActiveTabs(): Promise<any[]> { static async getActiveTabs(): Promise<chrome.tabs.Tab[]> {
return await BrowserApi.tabsQuery({ return await BrowserApi.tabsQuery({
active: true, active: true,
}); });
} }
static async tabsQuery(options: any): Promise<any[]> { static async tabsQuery(options: chrome.tabs.QueryInfo): Promise<chrome.tabs.Tab[]> {
return new Promise(resolve => { return new Promise(resolve => {
chrome.tabs.query(options, (tabs: any[]) => { chrome.tabs.query(options, (tabs: any[]) => {
resolve(tabs); resolve(tabs);
@@ -39,7 +39,7 @@ export class BrowserApi {
}); });
} }
static async tabsQueryFirst(options: any): Promise<any> { static async tabsQueryFirst(options: chrome.tabs.QueryInfo): Promise<chrome.tabs.Tab> | null {
const tabs = await BrowserApi.tabsQuery(options); const tabs = await BrowserApi.tabsQuery(options);
if (tabs.length > 0) { if (tabs.length > 0) {
return tabs[0]; return tabs[0];