Skip to content

Commit

Permalink
[PM-14426] Open the getting started carousel on page load
Browse files Browse the repository at this point in the history
  • Loading branch information
shane-melton committed Feb 12, 2025
1 parent 4547097 commit 14ff3e9
Showing 1 changed file with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CommonModule } from "@angular/common";
import { Component, inject, signal } from "@angular/core";
import { Component, inject, OnInit, signal } from "@angular/core";
import { Router } from "@angular/router";
import { combineLatest, firstValueFrom, map, of, shareReplay, startWith, switchMap } from "rxjs";

Expand All @@ -19,6 +19,8 @@ import {
BadgeModule,
ButtonModule,
CalloutModule,
DialogModule,
DialogService,
ItemModule,
ToastService,
TypographyModule,
Expand All @@ -30,11 +32,16 @@ import {
PasswordRepromptService,
SecurityTaskType,
TaskService,
VaultCarouselModule,
} from "@bitwarden/vault";

import { PopOutComponent } from "../../../../platform/popup/components/pop-out.component";
import { PopupHeaderComponent } from "../../../../platform/popup/layout/popup-header.component";
import { PopupPageComponent } from "../../../../platform/popup/layout/popup-page.component";
import {
AtRiskCarouselDialogComponent,
AtRiskCarouselDialogResult,
} from "../at-risk-carousel-dialog/at-risk-carousel-dialog.component";

import { AtRiskPasswordPageService } from "./at-risk-password-page.service";

Expand All @@ -50,6 +57,8 @@ import { AtRiskPasswordPageService } from "./at-risk-password-page.service";
CalloutModule,
ButtonModule,
BadgeModule,
DialogModule,
VaultCarouselModule,
],
providers: [
AtRiskPasswordPageService,
Expand All @@ -59,7 +68,7 @@ import { AtRiskPasswordPageService } from "./at-risk-password-page.service";
standalone: true,
templateUrl: "./at-risk-passwords.component.html",
})
export class AtRiskPasswordsComponent {
export class AtRiskPasswordsComponent implements OnInit {
private taskService = inject(TaskService);
private organizationService = inject(OrganizationService);
private cipherService = inject(CipherService);
Expand All @@ -72,6 +81,7 @@ export class AtRiskPasswordsComponent {
private atRiskPasswordPageService = inject(AtRiskPasswordPageService);
private changeLoginPasswordService = inject(ChangeLoginPasswordService);
private platformUtilsService = inject(PlatformUtilsService);
private dialogService = inject(DialogService);

/**
* The cipher that is currently being launched. Used to show a loading spinner on the badge button.
Expand Down Expand Up @@ -141,6 +151,21 @@ export class AtRiskPasswordsComponent {
}),
);

async ngOnInit() {
const { userId } = await firstValueFrom(this.activeUserData$);
const gettingStartedDismissed = await firstValueFrom(
this.atRiskPasswordPageService.isGettingStartedDismissed(userId),
);
if (!gettingStartedDismissed) {
const ref = AtRiskCarouselDialogComponent.open(this.dialogService);

Check warning on line 160 in apps/browser/src/vault/popup/components/at-risk-passwords/at-risk-passwords.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/vault/popup/components/at-risk-passwords/at-risk-passwords.component.ts#L160

Added line #L160 was not covered by tests

const result = await firstValueFrom(ref.closed);

Check warning on line 162 in apps/browser/src/vault/popup/components/at-risk-passwords/at-risk-passwords.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/vault/popup/components/at-risk-passwords/at-risk-passwords.component.ts#L162

Added line #L162 was not covered by tests
if (result === AtRiskCarouselDialogResult.Dismissed) {
await this.atRiskPasswordPageService.dismissGettingStarted(userId);

Check warning on line 164 in apps/browser/src/vault/popup/components/at-risk-passwords/at-risk-passwords.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/vault/popup/components/at-risk-passwords/at-risk-passwords.component.ts#L164

Added line #L164 was not covered by tests
}
}
}

async viewCipher(cipher: CipherView) {
const repromptPassed = await this.passwordRepromptService.passwordRepromptCheck(cipher);
if (!repromptPassed) {
Expand Down

0 comments on commit 14ff3e9

Please sign in to comment.