diff --git a/apps/web/src/app/vault/individual-vault/folder-add-edit.component.ts b/apps/web/src/app/vault/individual-vault/folder-add-edit.component.ts index 734b7179ac..fe61d9b9a1 100644 --- a/apps/web/src/app/vault/individual-vault/folder-add-edit.component.ts +++ b/apps/web/src/app/vault/individual-vault/folder-add-edit.component.ts @@ -8,7 +8,7 @@ import { LogService } from "@bitwarden/common/platform/abstractions/log.service" import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction"; import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction"; -import { DialogService } from "@bitwarden/components"; +import { DialogService, ToastService } from "@bitwarden/components"; @Component({ selector: "app-folder-add-edit", @@ -24,6 +24,7 @@ export class FolderAddEditComponent extends BaseFolderAddEditComponent { logService: LogService, dialogService: DialogService, formBuilder: FormBuilder, + protected toastService: ToastService, protected dialogRef: DialogRef, @Inject(DIALOG_DATA) params: FolderAddEditDialogParams, ) { @@ -51,10 +52,12 @@ export class FolderAddEditComponent extends BaseFolderAddEditComponent { } try { - this.deletePromise = this.folderApiService.delete(this.folder.id); - await this.deletePromise; - this.platformUtilsService.showToast("success", null, this.i18nService.t("deletedFolder")); - this.onDeletedFolder.emit(this.folder); + await this.folderApiService.delete(this.folder.id); + this.toastService.showToast({ + variant: "success", + title: null, + message: this.i18nService.t("deletedFolder"), + }); } catch (e) { this.logService.error(e); } diff --git a/apps/web/src/app/vault/individual-vault/vault.component.ts b/apps/web/src/app/vault/individual-vault/vault.component.ts index 7d17141e59..1de2dd3b5b 100644 --- a/apps/web/src/app/vault/individual-vault/vault.component.ts +++ b/apps/web/src/app/vault/individual-vault/vault.component.ts @@ -464,9 +464,7 @@ export class VaultComponent implements OnInit, OnDestroy { const result = await lastValueFrom(dialog.closed); if (result === FolderAddEditDialogResult.Deleted) { - // 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.router.navigate([], { + await this.router.navigate([], { queryParams: { folderId: null }, queryParamsHandling: "merge", replaceUrl: true, diff --git a/libs/common/src/vault/services/folder/folder.service.ts b/libs/common/src/vault/services/folder/folder.service.ts index 17d9f39f8e..7de7222edc 100644 --- a/libs/common/src/vault/services/folder/folder.service.ts +++ b/libs/common/src/vault/services/folder/folder.service.ts @@ -137,16 +137,14 @@ export class FolderService implements InternalFolderServiceAbstraction { return; } - if (typeof id === "string") { - if (folders[id] == null) { - return; + const folderIdsToDelete = Array.isArray(id) ? id : [id]; + + folderIdsToDelete.forEach((id) => { + if (folders[id] != null) { + delete folders[id]; } - delete folders[id]; - } else { - (id as string[]).forEach((i) => { - delete folders[i]; - }); - } + }); + return folders; });