From d68433c8670fc980a36ae3e124ed15a1e57128b5 Mon Sep 17 00:00:00 2001 From: tophf Date: Fri, 1 Jul 2022 07:55:11 +0300 Subject: [PATCH] fix usage of `chrome.windows` in android --- background/background.js | 2 +- background/token-manager.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/background/background.js b/background/background.js index c2fc7898..a8e5dd02 100644 --- a/background/background.js +++ b/background/background.js @@ -70,7 +70,7 @@ addAPI(/** @namespace API */ { async openEditor(params) { const u = new URL(chrome.runtime.getURL('edit.html')); u.search = new URLSearchParams(params); - const wnd = prefs.get('openEditInWindow'); + const wnd = chrome.windows && prefs.get('openEditInWindow'); const wndPos = wnd && prefs.get('windowPosition'); const wndBase = wnd && prefs.get('openEditInWindow.popup') ? {type: 'popup'} : {}; const ffBug = wnd && FIREFOX; // https://bugzil.la/1271047 diff --git a/background/token-manager.js b/background/token-manager.js index 153165a7..59247ef2 100644 --- a/background/token-manager.js +++ b/background/token-manager.js @@ -59,7 +59,7 @@ const tokenMan = (() => { const NETWORK_LATENCY = 30; // seconds const DEFAULT_REDIRECT_URI = 'https://clngdbkpkpeebahjckkjfobafhncgmne.chromiumapp.org/'; - let alwaysUseTab = FIREFOX ? false : null; + let alwaysUseTab = !chrome.windows || (FIREFOX ? false : null); class TokenError extends Error { constructor(provider, message) { @@ -167,13 +167,13 @@ const tokenMan = (() => { const url = `${provider.authURL}?${new URLSearchParams(query)}`; const width = Math.min(screen.availWidth - 100, 800); const height = Math.min(screen.availHeight - 100, 800); - const wnd = await browser.windows.getLastFocused(); + const wnd = !alwaysUseTab && await browser.windows.getLastFocused(); const finalUrl = await webextLaunchWebAuthFlow({ url, alwaysUseTab, interactive, redirect_uri: query.redirect_uri, - windowOptions: Object.assign({ + windowOptions: wnd && Object.assign({ state: 'normal', width, height,