1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-25 12:15:18 +01:00

[PM-13715] Launching a website from the extension does not trigger an update to reference the correct autofill value (#11587)

* [PM-13715] Launching page from cipher does not set correct autofill action

* [PM-13715] Fix autofill not triggering for correct cipher after page has been launched from browser extension
This commit is contained in:
Cesar Gonzalez 2024-10-24 08:22:43 -05:00 committed by GitHub
parent d5643f42b3
commit 9b471e6633
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 21 additions and 16 deletions

View File

@ -472,7 +472,7 @@
attr.aria-label="{{ 'launch' | i18n }} {{ u.uri }}" attr.aria-label="{{ 'launch' | i18n }} {{ u.uri }}"
appA11yTitle="{{ 'launch' | i18n }}" appA11yTitle="{{ 'launch' | i18n }}"
*ngIf="u.canLaunch" *ngIf="u.canLaunch"
(click)="launch(u)" (click)="launch(u, cipher.id)"
> >
<i class="bwi bwi-lg bwi-share-square" aria-hidden="true"></i> <i class="bwi bwi-lg bwi-share-square" aria-hidden="true"></i>
</button> </button>

View File

@ -348,15 +348,13 @@ export class ViewComponent implements OnDestroy, OnInit {
} }
} }
launch(uri: Launchable, cipherId?: string) { async launch(uri: Launchable, cipherId?: string) {
if (!uri.canLaunch) { if (!uri.canLaunch) {
return; return;
} }
if (cipherId) { if (cipherId) {
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling. await this.cipherService.updateLastLaunchedDate(cipherId);
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.cipherService.updateLastLaunchedDate(cipherId);
} }
this.platformUtilsService.launchUri(uri.launchUri); this.platformUtilsService.launchUri(uri.launchUri);

View File

@ -650,14 +650,11 @@ export class CipherService implements CipherServiceAbstraction {
ciphersLocalData = {}; ciphersLocalData = {};
} }
const cipherId = id as CipherId; const currentTime = new Date().getTime();
if (ciphersLocalData[cipherId]) { ciphersLocalData[id as CipherId] = {
ciphersLocalData[cipherId].lastLaunched = new Date().getTime(); lastLaunched: currentTime,
} else { lastUsedDate: currentTime,
ciphersLocalData[cipherId] = {
lastUsedDate: new Date().getTime(),
}; };
}
await this.localDataState.update(() => ciphersLocalData); await this.localDataState.update(() => ciphersLocalData);

View File

@ -3,6 +3,7 @@ import { Component, Input } from "@angular/core";
import { JslibModule } from "@bitwarden/angular/jslib.module"; import { JslibModule } from "@bitwarden/angular/jslib.module";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { LoginUriView } from "@bitwarden/common/vault/models/view/login-uri.view"; import { LoginUriView } from "@bitwarden/common/vault/models/view/login-uri.view";
import { import {
CardComponent, CardComponent,
@ -30,10 +31,15 @@ import {
}) })
export class AutofillOptionsViewComponent { export class AutofillOptionsViewComponent {
@Input() loginUris: LoginUriView[]; @Input() loginUris: LoginUriView[];
@Input() cipherId: string;
constructor(private platformUtilsService: PlatformUtilsService) {} constructor(
private platformUtilsService: PlatformUtilsService,
private cipherService: CipherService,
) {}
openWebsite(selectedUri: string) { async openWebsite(selectedUri: string) {
await this.cipherService.updateLastLaunchedDate(this.cipherId);
this.platformUtilsService.launchUri(selectedUri); this.platformUtilsService.launchUri(selectedUri);
} }
} }

View File

@ -25,7 +25,11 @@
<app-login-credentials-view *ngIf="hasLogin" [cipher]="cipher"></app-login-credentials-view> <app-login-credentials-view *ngIf="hasLogin" [cipher]="cipher"></app-login-credentials-view>
<!-- AUTOFILL OPTIONS --> <!-- AUTOFILL OPTIONS -->
<app-autofill-options-view *ngIf="hasAutofill" [loginUris]="cipher.login.uris"> <app-autofill-options-view
*ngIf="hasAutofill"
[loginUris]="cipher.login.uris"
[cipherId]="cipher.id"
>
</app-autofill-options-view> </app-autofill-options-view>
<!-- CARD DETAILS --> <!-- CARD DETAILS -->