Skip to content

Commit

Permalink
Fix code that results to a failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
martgil committed Jun 4, 2024
1 parent 4568417 commit 9c06611
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
14 changes: 11 additions & 3 deletions extension/js/common/browser/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,21 @@ export class Browser {
public static openSettingsPage = async (path = 'index.htm', acctEmail?: string, page = '', rawPageUrlParams?: Dict<UrlParam>, addNewAcct = false) => {
const basePath = chrome.runtime.getURL(`chrome/settings/${path}`);
const pageUrlParams = rawPageUrlParams ? JSON.stringify(rawPageUrlParams) : undefined;
const preferedLinkOpener = Catch.browser().name === 'thunderbird' ? BgUtils : Browser;
if (acctEmail || path === 'fatal.htm') {
await BgUtils.openExtensionTab(Url.create(basePath, { acctEmail, page, pageUrlParams }));
await preferedLinkOpener.openExtensionTab(Url.create(basePath, { acctEmail, page, pageUrlParams }));
} else if (addNewAcct) {
await BgUtils.openExtensionTab(Url.create(basePath, { addNewAcct }));
await preferedLinkOpener.openExtensionTab(Url.create(basePath, { addNewAcct }));
} else {
const acctEmails = await GlobalStore.acctEmailsGet();
await BgUtils.openExtensionTab(Url.create(basePath, { acctEmail: acctEmails[0], page, pageUrlParams }));
await preferedLinkOpener.openExtensionTab(Url.create(basePath, { acctEmail: acctEmails[0], page, pageUrlParams }));
}
};

public static openExtensionTab = (url: string) => {
const tab = window.open(url, 'flowcrypt');
if (tab) {
tab.focus();
}
};
}
3 changes: 2 additions & 1 deletion extension/js/common/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,9 @@ export class Settings {

public static async loginWithPopupShowModalOnErr(acctEmail: string, then: () => void = () => undefined) {
if (window !== window.top && !chrome.windows) {
const preferedLinkOpener = Catch.browser().name === 'thunderbird' ? BgUtils : Browser;
// Firefox, chrome.windows isn't available in iframes
await BgUtils.openExtensionTab(Url.create(chrome.runtime.getURL(`chrome/settings/index.htm`), { acctEmail }));
await preferedLinkOpener.openExtensionTab(Url.create(chrome.runtime.getURL(`chrome/settings/index.htm`), { acctEmail }));
await Ui.modal.info(`Reload after logging in.`);
return window.location.reload();
}
Expand Down

0 comments on commit 9c06611

Please sign in to comment.