1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-01 08:31:59 +00:00

fix(web): restore button in asset viewer (#8935)

* fix(web): restore button added to trashed asset-view to restore single item

* fixed the asset-viewer menu to update upon restoration

* prettier formatting complete, testing passed

* chore: clean up

---------

Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
This commit is contained in:
Conner 2024-04-19 19:19:50 -06:00 committed by GitHub
parent 171b6bb0a6
commit 3abfe3c99e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 33 additions and 7 deletions

View file

@ -20,6 +20,7 @@
mdiFolderDownloadOutline, mdiFolderDownloadOutline,
mdiHeart, mdiHeart,
mdiHeartOutline, mdiHeartOutline,
mdiHistory,
mdiImageAlbum, mdiImageAlbum,
mdiImageMinusOutline, mdiImageMinusOutline,
mdiImageOutline, mdiImageOutline,
@ -52,6 +53,7 @@
type MenuItemEvent = type MenuItemEvent =
| 'addToAlbum' | 'addToAlbum'
| 'restoreAsset'
| 'addToSharedAlbum' | 'addToSharedAlbum'
| 'asProfileImage' | 'asProfileImage'
| 'setAsAlbumCover' | 'setAsAlbumCover'
@ -70,6 +72,7 @@
delete: void; delete: void;
toggleArchive: void; toggleArchive: void;
addToAlbum: void; addToAlbum: void;
restoreAsset: void;
addToSharedAlbum: void; addToSharedAlbum: void;
asProfileImage: void; asProfileImage: void;
setAsAlbumCover: void; setAsAlbumCover: void;
@ -208,12 +211,16 @@
{#if showDownloadButton} {#if showDownloadButton}
<MenuOption icon={mdiFolderDownloadOutline} on:click={() => onMenuClick('download')} text="Download" /> <MenuOption icon={mdiFolderDownloadOutline} on:click={() => onMenuClick('download')} text="Download" />
{/if} {/if}
<MenuOption icon={mdiImageAlbum} on:click={() => onMenuClick('addToAlbum')} text="Add to album" /> {#if asset.isTrashed}
<MenuOption <MenuOption icon={mdiHistory} on:click={() => onMenuClick('restoreAsset')} text="Restore" />
icon={mdiShareVariantOutline} {:else}
on:click={() => onMenuClick('addToSharedAlbum')} <MenuOption icon={mdiImageAlbum} on:click={() => onMenuClick('addToAlbum')} text="Add to album" />
text="Add to shared album" <MenuOption
/> icon={mdiShareVariantOutline}
on:click={() => onMenuClick('addToSharedAlbum')}
text="Add to shared album"
/>
{/if}
{#if isOwner} {#if isOwner}
{#if hasStackChildren} {#if hasStackChildren}

View file

@ -27,6 +27,7 @@
getActivityStatistics, getActivityStatistics,
getAllAlbums, getAllAlbums,
runAssetJobs, runAssetJobs,
restoreAssets,
updateAsset, updateAsset,
updateAlbumInfo, updateAlbumInfo,
type ActivityResponseDto, type ActivityResponseDto,
@ -403,6 +404,22 @@
await handleGetAllAlbums(); await handleGetAllAlbums();
}; };
const handleRestoreAsset = async () => {
try {
await restoreAssets({ bulkIdsDto: { ids: [asset.id] } });
asset.isTrashed = false;
dispatch('action', { type: AssetAction.RESTORE, asset });
notificationController.show({
type: NotificationType.Info,
message: `Restored asset`,
});
} catch (error) {
handleError(error, 'Error restoring asset');
}
};
const toggleArchive = async () => { const toggleArchive = async () => {
try { try {
const data = await updateAsset({ const data = await updateAsset({
@ -556,6 +573,7 @@
on:delete={() => trashOrDelete()} on:delete={() => trashOrDelete()}
on:favorite={toggleFavorite} on:favorite={toggleFavorite}
on:addToAlbum={() => openAlbumPicker(false)} on:addToAlbum={() => openAlbumPicker(false)}
on:restoreAsset={() => handleRestoreAsset()}
on:addToSharedAlbum={() => openAlbumPicker(true)} on:addToSharedAlbum={() => openAlbumPicker(true)}
on:playMotionPhoto={() => (shouldPlayMotionPhoto = true)} on:playMotionPhoto={() => (shouldPlayMotionPhoto = true)}
on:stopMotionPhoto={() => (shouldPlayMotionPhoto = false)} on:stopMotionPhoto={() => (shouldPlayMotionPhoto = false)}

View file

@ -169,6 +169,7 @@
switch (action) { switch (action) {
case removeAction: case removeAction:
case AssetAction.TRASH: case AssetAction.TRASH:
case AssetAction.RESTORE:
case AssetAction.DELETE: { case AssetAction.DELETE: {
// find the next asset to show or close the viewer // find the next asset to show or close the viewer
(await handleNext()) || (await handlePrevious()) || handleClose(); (await handleNext()) || (await handlePrevious()) || handleClose();

View file

@ -5,7 +5,7 @@ export enum AssetAction {
UNFAVORITE = 'unfavorite', UNFAVORITE = 'unfavorite',
TRASH = 'trash', TRASH = 'trash',
DELETE = 'delete', DELETE = 'delete',
// RESTORE = 'restore', RESTORE = 'restore',
ADD = 'add', ADD = 'add',
} }