feat(web): improved action bar actions (#2553)

* feat(web): improved action bar actions

* Update web/src/lib/components/photos-page/actions/delete-assets.svelte

Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com>

* update archive and favorite actions

* feat: add un archive/favorite on associated pages

* fix favorite action + use isAllArchived for photos

* remove unneeded unarchive check

---------

Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com>
This commit is contained in:
Jason Rasmussen
2023-05-26 09:11:10 -04:00
committed by GitHub
parent 71ef7685c5
commit d6756f3d81
20 changed files with 253 additions and 276 deletions
@@ -7,39 +7,47 @@
import { api } from '@api';
import DeleteOutline from 'svelte-material-icons/DeleteOutline.svelte';
import { OnAssetDelete, getAssetControlContext } from '../asset-select-control-bar.svelte';
import ConfirmDialogue from '$lib/components/shared-components/confirm-dialogue.svelte';
import { handleError } from '../../../utils/handle-error';
export let onAssetDelete: OnAssetDelete;
const { getAssets, clearSelect } = getAssetControlContext();
const deleteSelectedAssetHandler = async () => {
let confirm = false;
const handleDelete = async () => {
try {
if (
window.confirm(
`Caution! Are you sure you want to delete ${
getAssets().size
} assets? This step also deletes assets in the album(s) to which they belong. You can not undo this action!`
)
) {
const { data: deletedAssets } = await api.assetApi.deleteAsset({
ids: Array.from(getAssets()).map((a) => a.id)
});
let count = 0;
for (const asset of deletedAssets) {
if (asset.status === 'SUCCESS') {
onAssetDelete(asset.id);
}
}
clearSelect();
}
} catch (e) {
notificationController.show({
type: NotificationType.Error,
message: 'Error deleting assets, check console for more details'
const { data: deletedAssets } = await api.assetApi.deleteAsset({
ids: Array.from(getAssets()).map((a) => a.id)
});
console.error('Error deleteSelectedAssetHandler', e);
for (const asset of deletedAssets) {
if (asset.status === 'SUCCESS') {
onAssetDelete(asset.id);
count++;
}
}
notificationController.show({ message: `Deleted ${count}`, type: NotificationType.Info });
clearSelect();
} catch (e) {
handleError(e, 'Error deleting assets');
}
};
</script>
<CircleIconButton title="Delete" logo={DeleteOutline} on:click={deleteSelectedAssetHandler} />
<CircleIconButton title="Delete" logo={DeleteOutline} on:click={() => (confirm = true)} />
{#if confirm}
<ConfirmDialogue
prompt="Are you sure you want to delete {getAssets()
.size} assets? This step also deletes assets in the album(s) to which they belong. You can not undo this action!"
title="Delete assets?"
confirmText="Delete"
on:confirm={handleDelete}
on:cancel={() => (confirm = false)}
/>
{/if}