mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 22:03:36 +00:00
[PM-8050] Deleting one folder deletes all other folders (#10165)
* removed the use of deletepromise from folder edit dialog on web * resolved fix me * return folders if folder is not found with folder id
This commit is contained in:
@@ -8,7 +8,7 @@ import { LogService } from "@bitwarden/common/platform/abstractions/log.service"
|
|||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
|
import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
|
||||||
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.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({
|
@Component({
|
||||||
selector: "app-folder-add-edit",
|
selector: "app-folder-add-edit",
|
||||||
@@ -24,6 +24,7 @@ export class FolderAddEditComponent extends BaseFolderAddEditComponent {
|
|||||||
logService: LogService,
|
logService: LogService,
|
||||||
dialogService: DialogService,
|
dialogService: DialogService,
|
||||||
formBuilder: FormBuilder,
|
formBuilder: FormBuilder,
|
||||||
|
protected toastService: ToastService,
|
||||||
protected dialogRef: DialogRef<FolderAddEditDialogResult>,
|
protected dialogRef: DialogRef<FolderAddEditDialogResult>,
|
||||||
@Inject(DIALOG_DATA) params: FolderAddEditDialogParams,
|
@Inject(DIALOG_DATA) params: FolderAddEditDialogParams,
|
||||||
) {
|
) {
|
||||||
@@ -51,10 +52,12 @@ export class FolderAddEditComponent extends BaseFolderAddEditComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.deletePromise = this.folderApiService.delete(this.folder.id);
|
await this.folderApiService.delete(this.folder.id);
|
||||||
await this.deletePromise;
|
this.toastService.showToast({
|
||||||
this.platformUtilsService.showToast("success", null, this.i18nService.t("deletedFolder"));
|
variant: "success",
|
||||||
this.onDeletedFolder.emit(this.folder);
|
title: null,
|
||||||
|
message: this.i18nService.t("deletedFolder"),
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logService.error(e);
|
this.logService.error(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -464,9 +464,7 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
const result = await lastValueFrom(dialog.closed);
|
const result = await lastValueFrom(dialog.closed);
|
||||||
|
|
||||||
if (result === FolderAddEditDialogResult.Deleted) {
|
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.
|
await this.router.navigate([], {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
||||||
this.router.navigate([], {
|
|
||||||
queryParams: { folderId: null },
|
queryParams: { folderId: null },
|
||||||
queryParamsHandling: "merge",
|
queryParamsHandling: "merge",
|
||||||
replaceUrl: true,
|
replaceUrl: true,
|
||||||
|
|||||||
@@ -137,16 +137,14 @@ export class FolderService implements InternalFolderServiceAbstraction {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof id === "string") {
|
const folderIdsToDelete = Array.isArray(id) ? id : [id];
|
||||||
if (folders[id] == null) {
|
|
||||||
return;
|
folderIdsToDelete.forEach((id) => {
|
||||||
}
|
if (folders[id] != null) {
|
||||||
delete folders[id];
|
delete folders[id];
|
||||||
} else {
|
|
||||||
(id as string[]).forEach((i) => {
|
|
||||||
delete folders[i];
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return folders;
|
return folders;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user