mirror of
https://github.com/Eugeny/tabby.git
synced 2025-09-24 09:06:03 +00:00
avoid multiple parallel passphrase prompts - fixes #4811
This commit is contained in:
@@ -3,7 +3,7 @@ import { promisify } from 'util'
|
|||||||
import { Injectable, NgZone } from '@angular/core'
|
import { Injectable, NgZone } from '@angular/core'
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||||
import { AsyncSubject, Subject, Observable } from 'rxjs'
|
import { AsyncSubject, Subject, Observable } from 'rxjs'
|
||||||
import { wrapPromise } from '../utils'
|
import { wrapPromise, serializeFunction } from '../utils'
|
||||||
import { UnlockVaultModalComponent } from '../components/unlockVaultModal.component'
|
import { UnlockVaultModalComponent } from '../components/unlockVaultModal.component'
|
||||||
import { NotificationsService } from './notifications.service'
|
import { NotificationsService } from './notifications.service'
|
||||||
import { SelectorService } from './selector.service'
|
import { SelectorService } from './selector.service'
|
||||||
@@ -114,7 +114,9 @@ export class VaultService {
|
|||||||
private zone: NgZone,
|
private zone: NgZone,
|
||||||
private notifications: NotificationsService,
|
private notifications: NotificationsService,
|
||||||
private ngbModal: NgbModal,
|
private ngbModal: NgbModal,
|
||||||
) { }
|
) {
|
||||||
|
this.getPassphrase = serializeFunction(this.getPassphrase.bind(this))
|
||||||
|
}
|
||||||
|
|
||||||
async setEnabled (enabled: boolean, passphrase?: string): Promise<void> {
|
async setEnabled (enabled: boolean, passphrase?: string): Promise<void> {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
|
@@ -64,3 +64,12 @@ export const TAB_COLORS = [
|
|||||||
{ name: 'Red', value: '#d9534f' },
|
{ name: 'Red', value: '#d9534f' },
|
||||||
{ name: 'Yellow', value: '#ffd500' },
|
{ name: 'Yellow', value: '#ffd500' },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
export function serializeFunction <T extends () => Promise<any>> (fn: T): T {
|
||||||
|
let queue = Promise.resolve()
|
||||||
|
return (...args) => {
|
||||||
|
const res = queue.then(() => fn(...args))
|
||||||
|
queue = res.catch(() => null)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user