1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-08-27 23:31:41 +02:00

[PM-6426] Fixing how we check for the browser alarms api

This commit is contained in:
Cesar Gonzalez 2024-04-02 16:07:30 -05:00
parent 428937d1a8
commit dbbc07b08b
No known key found for this signature in database
GPG Key ID: 3381A5457F8CCECF

View File

@ -599,7 +599,7 @@ export class BrowserApi {
* @param alarmName - The name of the alarm to create.
*/
static clearAlarm(alarmName: string): Promise<boolean> {
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<boolean> {
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<void> {
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<chrome.alarms.Alarm> {
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<chrome.alarms.Alarm[]> {
if (typeof browser?.alarms !== "undefined") {
if (typeof browser !== "undefined" && browser.alarms) {
return browser.alarms.getAll();
}