mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-02 08:40:08 +01:00
async fillCipher
This commit is contained in:
parent
4d261964e5
commit
e6d6275daa
@ -229,7 +229,7 @@ export class BrowserApi {
|
||||
browser.tabs.update({ active: true }).finally(win.close);
|
||||
} else if (BrowserApi.isWebExtensionsApi || BrowserApi.isChromeApi) {
|
||||
win.close();
|
||||
} else if (BrowserApi.isSafariApi && safari.extension.popovers && safari.extension.popovers.length > 0) {
|
||||
} else if (BrowserApi.isSafariApi) {
|
||||
SafariApp.sendMessageToApp('hideWindow');
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
|
||||
this.router.navigate(['/view-cipher'], { queryParams: { cipherId: cipher.id } });
|
||||
}
|
||||
|
||||
fillCipher(cipher: CipherView) {
|
||||
async fillCipher(cipher: CipherView) {
|
||||
this.totpCode = null;
|
||||
if (this.totpTimeout != null) {
|
||||
window.clearTimeout(this.totpTimeout);
|
||||
@ -142,27 +142,26 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
|
||||
return;
|
||||
}
|
||||
|
||||
this.autofillService.doAutoFill({
|
||||
try {
|
||||
this.totpCode = await this.autofillService.doAutoFill({
|
||||
cipher: cipher,
|
||||
pageDetails: this.pageDetails,
|
||||
doc: window.document,
|
||||
}).then((totpCode) => {
|
||||
this.totpCode = totpCode;
|
||||
});
|
||||
this.analytics.eventTrack.next({ action: 'Autofilled' });
|
||||
if (totpCode != null && !this.platformUtilsService.isSafari()) {
|
||||
this.platformUtilsService.copyToClipboard(totpCode, { window: window });
|
||||
if (this.totpCode != null && !this.platformUtilsService.isSafari()) {
|
||||
this.platformUtilsService.copyToClipboard(this.totpCode, { window: window });
|
||||
}
|
||||
|
||||
if (this.popupUtilsService.inPopup(window)) {
|
||||
BrowserApi.closePopup(window);
|
||||
}
|
||||
}).catch(() => {
|
||||
} catch {
|
||||
this.ngZone.run(() => {
|
||||
this.analytics.eventTrack.next({ action: 'Autofilled Error' });
|
||||
this.toasterService.popAsync('error', null, this.i18nService.t('autofillError'));
|
||||
this.changeDetectorRef.detectChanges();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Weird bug in Safari won't allow clipboard copying after a promise call, so we have this workaround
|
||||
if (cipher.type === CipherType.Login && this.platformUtilsService.isSafari()) {
|
||||
|
Loading…
Reference in New Issue
Block a user