Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ <h2 class="box-header">
attr.aria-label="{{ 'launch' | i18n }} {{ u.uri }}"
appA11yTitle="{{ 'launch' | i18n }}"
*ngIf="u.canLaunch"
(click)="launch(u)"
(click)="launch(u, cipher.id)"
>
<i class="bwi bwi-lg bwi-share-square" aria-hidden="true"></i>
</button>
Expand Down
6 changes: 2 additions & 4 deletions libs/angular/src/vault/components/view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,15 +340,13 @@
}
}

launch(uri: Launchable, cipherId?: string) {
async launch(uri: Launchable, cipherId?: string) {
if (!uri.canLaunch) {
return;
}

if (cipherId) {
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.cipherService.updateLastLaunchedDate(cipherId);
await this.cipherService.updateLastLaunchedDate(cipherId);

Check warning on line 349 in libs/angular/src/vault/components/view.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/angular/src/vault/components/view.component.ts#L349

Added line #L349 was not covered by tests
}

this.platformUtilsService.launchUri(uri.launchUri);
Expand Down
13 changes: 5 additions & 8 deletions libs/common/src/vault/services/cipher.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,14 +650,11 @@
ciphersLocalData = {};
}

const cipherId = id as CipherId;
if (ciphersLocalData[cipherId]) {
ciphersLocalData[cipherId].lastLaunched = new Date().getTime();
} else {
ciphersLocalData[cipherId] = {
lastUsedDate: new Date().getTime(),
};
}
const currentTime = new Date().getTime();
ciphersLocalData[id as CipherId] = {

Check warning on line 654 in libs/common/src/vault/services/cipher.service.ts

View check run for this annotation

Codecov / codecov/patch

libs/common/src/vault/services/cipher.service.ts#L653-L654

Added lines #L653 - L654 were not covered by tests
lastLaunched: currentTime,
lastUsedDate: currentTime,
};

await this.localDataState.update(() => ciphersLocalData);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import { JslibModule } from "@bitwarden/angular/jslib.module";
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 {
CardComponent,
Expand Down Expand Up @@ -30,10 +31,15 @@
})
export class AutofillOptionsViewComponent {
@Input() loginUris: LoginUriView[];
@Input() cipherId: string;

constructor(private platformUtilsService: PlatformUtilsService) {}
constructor(
private platformUtilsService: PlatformUtilsService,
private cipherService: CipherService,

Check warning on line 38 in libs/vault/src/cipher-view/autofill-options/autofill-options-view.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/vault/src/cipher-view/autofill-options/autofill-options-view.component.ts#L38

Added line #L38 was not covered by tests
) {}

openWebsite(selectedUri: string) {
async openWebsite(selectedUri: string) {
await this.cipherService.updateLastLaunchedDate(this.cipherId);

Check warning on line 42 in libs/vault/src/cipher-view/autofill-options/autofill-options-view.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/vault/src/cipher-view/autofill-options/autofill-options-view.component.ts#L42

Added line #L42 was not covered by tests
this.platformUtilsService.launchUri(selectedUri);
}
}
6 changes: 5 additions & 1 deletion libs/vault/src/cipher-view/cipher-view.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
<app-login-credentials-view *ngIf="hasLogin" [cipher]="cipher"></app-login-credentials-view>

<!-- 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>

<!-- CARD DETAILS -->
Expand Down
Loading