1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 10:13:31 +00:00

Resolve safari not checking vault timeout every 10s (#1615)

This commit is contained in:
Oscar Hinton
2021-02-20 11:10:33 +01:00
committed by GitHub
parent ca6078e6e8
commit 2ac9f92267
4 changed files with 35 additions and 2 deletions

View File

@@ -0,0 +1,28 @@
import { VaultTimeoutService as BaseVaultTimeoutService } from 'jslib/services/vaultTimeout.service';
import { SafariApp } from '../browser/safariApp';
export default class VaultTimeoutService extends BaseVaultTimeoutService {
startCheck() {
this.checkVaultTimeout();
if (this.platformUtilsService.isSafari()) {
this.checkSafari();
} else {
setInterval(() => this.checkVaultTimeout(), 10 * 1000); // check every 10 seconds
}
}
// This is a work-around to safari adding an arbitary delay to setTimeout and
// setIntervals. It works by calling the native extension which sleeps for 10s,
// efficiently replicating setInterval.
async checkSafari() {
while(true) {
try {
await SafariApp.sendMessageToApp('sleep');
this.checkVaultTimeout();
} catch(e) {
console.log("Exception Safari VaultTimeout", e);
}
}
}
}