From e8979decae48bd5304bf8bccdd41098e8c4fc015 Mon Sep 17 00:00:00 2001 From: Justin Baur <19896123+justindbaur@users.noreply.github.com> Date: Tue, 17 Sep 2024 16:58:23 -0400 Subject: [PATCH] Add Back Safari Only Handling of Process Reload (#11115) --- apps/browser/src/background/main.background.ts | 8 ++++++++ apps/browser/src/popup/app.component.ts | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/apps/browser/src/background/main.background.ts b/apps/browser/src/background/main.background.ts index 9579fb2be8..f54f1de1dd 100644 --- a/apps/browser/src/background/main.background.ts +++ b/apps/browser/src/background/main.background.ts @@ -1038,6 +1038,14 @@ export default class MainBackground { const systemUtilsServiceReloadCallback = async () => { await this.taskSchedulerService.clearAllScheduledTasks(); + if (this.platformUtilsService.isSafari()) { + // If we do `chrome.runtime.reload` on safari they will send an onInstalled reason of install + // and that prompts us to show a new tab, this apparently doesn't happen on sideloaded + // extensions and only shows itself production scenarios. See: https://bitwarden.atlassian.net/browse/PM-12298 + self.location.reload(); + return; + } + BrowserApi.reloadExtension(); }; diff --git a/apps/browser/src/popup/app.component.ts b/apps/browser/src/popup/app.component.ts index 477152fff8..12d5b109c2 100644 --- a/apps/browser/src/popup/app.component.ts +++ b/apps/browser/src/popup/app.component.ts @@ -127,6 +127,12 @@ export class AppComponent implements OnInit, OnDestroy { this.showNativeMessagingFingerprintDialog(msg); } else if (msg.command === "showToast") { this.toastService._showToast(msg); + } else if (msg.command === "reloadProcess") { + if (this.platformUtilsService.isSafari()) { + window.setTimeout(() => { + window.location.reload(); + }, 2000); + } } else if (msg.command === "reloadPopup") { // FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling. // eslint-disable-next-line @typescript-eslint/no-floating-promises