mirror of
https://github.com/immich-app/immich.git
synced 2025-01-07 00:50:23 -05:00
fix(web): delete library (#10822)
This commit is contained in:
parent
04f0ac1aad
commit
f5937a5a9b
1 changed files with 18 additions and 47 deletions
|
@ -47,20 +47,11 @@
|
||||||
let totalCount: number[] = [];
|
let totalCount: number[] = [];
|
||||||
let diskUsage: number[] = [];
|
let diskUsage: number[] = [];
|
||||||
let diskUsageUnit: ByteUnit[] = [];
|
let diskUsageUnit: ByteUnit[] = [];
|
||||||
|
|
||||||
let confirmDeleteLibrary: LibraryResponseDto | null = null;
|
|
||||||
let deletedLibrary: LibraryResponseDto | null = null;
|
|
||||||
|
|
||||||
let editImportPaths: number | null;
|
let editImportPaths: number | null;
|
||||||
let editScanSettings: number | null;
|
let editScanSettings: number | null;
|
||||||
let renameLibrary: number | null;
|
let renameLibrary: number | null;
|
||||||
|
|
||||||
let updateLibraryIndex: number | null;
|
let updateLibraryIndex: number | null;
|
||||||
|
|
||||||
let deleteAssetCount = 0;
|
|
||||||
|
|
||||||
let dropdownOpen: boolean[] = [];
|
let dropdownOpen: boolean[] = [];
|
||||||
|
|
||||||
let toCreateLibrary = false;
|
let toCreateLibrary = false;
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
|
@ -127,30 +118,6 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDelete = async () => {
|
|
||||||
if (confirmDeleteLibrary) {
|
|
||||||
deletedLibrary = confirmDeleteLibrary;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!deletedLibrary) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
await deleteLibrary({ id: deletedLibrary.id });
|
|
||||||
notificationController.show({
|
|
||||||
message: $t('admin.library_deleted'),
|
|
||||||
type: NotificationType.Info,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
handleError(error, $t('errors.unable_to_remove_library'));
|
|
||||||
} finally {
|
|
||||||
confirmDeleteLibrary = null;
|
|
||||||
deletedLibrary = null;
|
|
||||||
await readLibraryList();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleScanAll = async () => {
|
const handleScanAll = async () => {
|
||||||
try {
|
try {
|
||||||
for (const library of libraries) {
|
for (const library of libraries) {
|
||||||
|
@ -260,36 +227,40 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onDeleteLibraryClicked = async (library: LibraryResponseDto, index: number) => {
|
const handleDelete = async (library: LibraryResponseDto, index: number) => {
|
||||||
closeAll();
|
closeAll();
|
||||||
|
|
||||||
if (!library) {
|
if (!library) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isConfirmedLibrary = await dialogController.show({
|
const isConfirmed = await dialogController.show({
|
||||||
prompt: $t('admin.confirm_delete_library', { values: { library: library.name } }),
|
prompt: $t('admin.confirm_delete_library', { values: { library: library.name } }),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!isConfirmedLibrary) {
|
if (!isConfirmed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await refreshStats(index);
|
await refreshStats(index);
|
||||||
if (totalCount[index] > 0) {
|
const assetCount = totalCount[index];
|
||||||
deleteAssetCount = totalCount[index];
|
if (assetCount > 0) {
|
||||||
|
const isConfirmed = await dialogController.show({
|
||||||
const isConfirmedLibraryAssetCount = await dialogController.show({
|
prompt: $t('admin.confirm_delete_library_assets', { values: { count: assetCount } }),
|
||||||
prompt: $t('admin.confirm_delete_library_assets', { values: { count: deleteAssetCount } }),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!isConfirmedLibraryAssetCount) {
|
if (!isConfirmed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await handleDelete();
|
}
|
||||||
} else {
|
|
||||||
deletedLibrary = library;
|
try {
|
||||||
await handleDelete();
|
await deleteLibrary({ id: library.id });
|
||||||
|
notificationController.show({ message: $t('admin.library_deleted'), type: NotificationType.Info });
|
||||||
|
} catch (error) {
|
||||||
|
handleError(error, $t('errors.unable_to_remove_library'));
|
||||||
|
} finally {
|
||||||
|
await readLibraryList();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -402,7 +373,7 @@
|
||||||
text={$t('delete_library')}
|
text={$t('delete_library')}
|
||||||
activeColor="bg-red-200"
|
activeColor="bg-red-200"
|
||||||
textColor="text-red-600"
|
textColor="text-red-600"
|
||||||
onClick={() => onDeleteLibraryClicked(library, index)}
|
onClick={() => handleDelete(library, index)}
|
||||||
/>
|
/>
|
||||||
</ButtonContextMenu>
|
</ButtonContextMenu>
|
||||||
</td>
|
</td>
|
||||||
|
|
Loading…
Reference in a new issue