From dbbc07b08b10112b3110d2f8de41b1cf20617b4a Mon Sep 17 00:00:00 2001 From: Cesar Gonzalez Date: Tue, 2 Apr 2024 16:07:30 -0500 Subject: [PATCH] [PM-6426] Fixing how we check for the browser alarms api --- apps/browser/src/platform/browser/browser-api.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/browser/src/platform/browser/browser-api.ts b/apps/browser/src/platform/browser/browser-api.ts index 7907651003..3bdda54a5e 100644 --- a/apps/browser/src/platform/browser/browser-api.ts +++ b/apps/browser/src/platform/browser/browser-api.ts @@ -599,7 +599,7 @@ export class BrowserApi { * @param alarmName - The name of the alarm to create. */ static clearAlarm(alarmName: string): Promise { - if (typeof browser?.alarms !== "undefined") { + if (typeof browser !== "undefined" && browser.alarms) { return browser.alarms.clear(alarmName); } @@ -611,7 +611,7 @@ export class BrowserApi { * that indicates when all alarms have been cleared successfully. */ static clearAllAlarms(): Promise { - if (typeof browser?.alarms !== "undefined") { + if (typeof browser !== "undefined" && browser.alarms) { return browser.alarms.clearAll(); } @@ -625,7 +625,7 @@ export class BrowserApi { * @param createInfo - The creation info for the alarm. */ static async createAlarm(name: string, createInfo: chrome.alarms.AlarmCreateInfo): Promise { - if (typeof browser?.alarms !== "undefined") { + if (typeof browser !== "undefined" && browser.alarms) { return browser.alarms.create(name, createInfo); } @@ -638,7 +638,7 @@ export class BrowserApi { * @param alarmName - The name of the alarm to get. */ static getAlarm(alarmName: string): Promise { - if (typeof browser?.alarms !== "undefined") { + if (typeof browser !== "undefined" && browser.alarms) { return browser.alarms.get(alarmName); } @@ -649,7 +649,7 @@ export class BrowserApi { * Gets all alarms that have been set by the extension. */ static getAllAlarms(): Promise { - if (typeof browser?.alarms !== "undefined") { + if (typeof browser !== "undefined" && browser.alarms) { return browser.alarms.getAll(); }