Skip to content

Commit

Permalink
[PM-8665] Show toast when favorite is toggled (#9537)
Browse files Browse the repository at this point in the history
  • Loading branch information
shane-melton authored Jun 6, 2024
1 parent 3457941 commit c8b2807
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
6 changes: 6 additions & 0 deletions apps/browser/src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,12 @@
"unfavorite": {
"message": "Unfavorite"
},
"itemAddedToFavorites": {
"message": "Item added to favorites"
},
"itemRemovedFromFavorites": {
"message": "Item removed from favorites"
},
"notes": {
"message": "Notes"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@ import { booleanAttribute, Component, Input } from "@angular/core";
import { Router, RouterModule } from "@angular/router";

import { JslibModule } from "@bitwarden/angular/jslib.module";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { CipherRepromptType, CipherType } from "@bitwarden/common/vault/enums";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { DialogService, IconButtonModule, ItemModule, MenuModule } from "@bitwarden/components";
import {
DialogService,
IconButtonModule,
ItemModule,
MenuModule,
ToastService,
} from "@bitwarden/components";
import { PasswordRepromptService } from "@bitwarden/vault";

import { BrowserApi } from "../../../../../platform/browser/browser-api";
Expand Down Expand Up @@ -38,8 +45,10 @@ export class ItemMoreOptionsComponent {
private cipherService: CipherService,
private vaultPopupItemsService: VaultPopupItemsService,
private passwordRepromptService: PasswordRepromptService,
private toastService: ToastService,
private dialogService: DialogService,
private router: Router,
private i18nService: I18nService,
) {}

get canEdit() {
Expand Down Expand Up @@ -85,6 +94,13 @@ export class ItemMoreOptionsComponent {
this.cipher.favorite = !this.cipher.favorite;
const encryptedCipher = await this.cipherService.encrypt(this.cipher);
await this.cipherService.updateWithServer(encryptedCipher);
this.toastService.showToast({
variant: "success",
title: null,
message: this.i18nService.t(
this.cipher.favorite ? "itemAddedToFavorites" : "itemRemovedFromFavorites",
),
});
}

/**
Expand Down

0 comments on commit c8b2807

Please sign in to comment.