diff --git a/tabby-core/src/services/vault.service.ts b/tabby-core/src/services/vault.service.ts index b7439e51de549d7a00d42c3d9804bfde942c9899..1e50cc7465a2b1bd398cd7a1c2db1b70f4cdbe27 100644 --- a/tabby-core/src/services/vault.service.ts +++ b/tabby-core/src/services/vault.service.ts @@ -3,7 +3,7 @@ import { promisify } from 'util' import { Injectable, NgZone } from '@angular/core' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { AsyncSubject, Subject, Observable } from 'rxjs' -import { wrapPromise } from '../utils' +import { wrapPromise, serializeFunction } from '../utils' import { UnlockVaultModalComponent } from '../components/unlockVaultModal.component' import { NotificationsService } from './notifications.service' import { SelectorService } from './selector.service' @@ -114,7 +114,9 @@ export class VaultService { private zone: NgZone, private notifications: NotificationsService, private ngbModal: NgbModal, - ) { } + ) { + this.getPassphrase = serializeFunction(this.getPassphrase.bind(this)) + } async setEnabled (enabled: boolean, passphrase?: string): Promise { if (enabled) { diff --git a/tabby-core/src/utils.ts b/tabby-core/src/utils.ts index 59821565835bd0f010d02c1c7abf38b7d8887bf6..4e7ce896fe305a46eee59fa41e96823a9b55da54 100644 --- a/tabby-core/src/utils.ts +++ b/tabby-core/src/utils.ts @@ -64,3 +64,12 @@ export const TAB_COLORS = [ { name: 'Red', value: '#d9534f' }, { name: 'Yellow', value: '#ffd500' }, ] + +export function serializeFunction Promise> (fn: T): T { + let queue = Promise.resolve() + return (...args) => { + const res = queue.then(() => fn(...args)) + queue = res.catch(() => null) + return res + } +}