From f004487be0d68d7c14891ee21d941607ee574d92 Mon Sep 17 00:00:00 2001 From: Conner Hnatiuk <46903591+ConnerWithAnE@users.noreply.github.com> Date: Sun, 21 Apr 2024 13:07:17 -0600 Subject: [PATCH] fix(web): trash page now auto refreshes (#8978) * fix(web): the trash page now auto refreshes when restore all or empty trash is clicked. Also shows number of assets affected. * formatting --- web/src/routes/(user)/trash/+page.svelte | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/web/src/routes/(user)/trash/+page.svelte b/web/src/routes/(user)/trash/+page.svelte index 5be97f2821..2728f25b02 100644 --- a/web/src/routes/(user)/trash/+page.svelte +++ b/web/src/routes/(user)/trash/+page.svelte @@ -39,8 +39,12 @@ try { await emptyTrash(); + const deletedAssetIds = assetStore.assets.map((a) => a.id); + const numberOfAssets = deletedAssetIds.length; + assetStore.removeAssets(deletedAssetIds); + notificationController.show({ - message: `Empty trash initiated. Refresh the page to see the changes`, + message: `Permanently deleted ${numberOfAssets} ${numberOfAssets == 1 ? 'asset' : 'assets'}`, type: NotificationType.Info, }); } catch (error) { @@ -52,8 +56,12 @@ try { await restoreTrash(); + const restoredAssetIds = assetStore.assets.map((a) => a.id); + const numberOfAssets = restoredAssetIds.length; + assetStore.removeAssets(restoredAssetIds); + notificationController.show({ - message: `Restore trash initiated. Refresh the page to see the changes`, + message: `Restored ${numberOfAssets} ${numberOfAssets == 1 ? 'asset' : 'assets'}`, type: NotificationType.Info, }); } catch (error) {