mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
fix(web): update stack state in timeline (#17021)
* fix(web): update stack state in timeline * js docs * fix: handle state update from unstack action from gallery viewer * use navigate in View Stack notification --------- Co-authored-by: Snowknight26 <Snowknight26@users.noreply.github.com>
This commit is contained in:
parent
b00da18e84
commit
b5d5c40c69
5 changed files with 78 additions and 22 deletions
|
|
@ -4,7 +4,6 @@ import type { InterpolationValues } from '$lib/components/i18n/format-message';
|
|||
import { NotificationType, notificationController } from '$lib/components/shared-components/notification/notification';
|
||||
import { AppRoute } from '$lib/constants';
|
||||
import type { AssetInteraction } from '$lib/stores/asset-interaction.svelte';
|
||||
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
||||
import { assetsSnapshot, isSelectingAllAssets, type AssetStore } from '$lib/stores/assets-store.svelte';
|
||||
import { downloadManager } from '$lib/stores/download';
|
||||
import { preferences } from '$lib/stores/user.store';
|
||||
|
|
@ -12,6 +11,7 @@ import { downloadRequest, getKey, withError } from '$lib/utils';
|
|||
import { createAlbum } from '$lib/utils/album-utils';
|
||||
import { getByteUnitString } from '$lib/utils/byte-units';
|
||||
import { getFormatter } from '$lib/utils/i18n';
|
||||
import { navigate } from '$lib/utils/navigation';
|
||||
import {
|
||||
addAssetsToAlbum as addAssets,
|
||||
createStack,
|
||||
|
|
@ -381,9 +381,14 @@ export const getSelectedAssets = (assets: AssetResponseDto[], user: UserResponse
|
|||
return ids;
|
||||
};
|
||||
|
||||
export const stackAssets = async (assets: AssetResponseDto[], showNotification = true) => {
|
||||
export type StackResponse = {
|
||||
stack?: StackResponseDto;
|
||||
toDeleteIds: string[];
|
||||
};
|
||||
|
||||
export const stackAssets = async (assets: AssetResponseDto[], showNotification = true): Promise<StackResponse> => {
|
||||
if (assets.length < 2) {
|
||||
return false;
|
||||
return { stack: undefined, toDeleteIds: [] };
|
||||
}
|
||||
|
||||
const $t = get(t);
|
||||
|
|
@ -396,7 +401,7 @@ export const stackAssets = async (assets: AssetResponseDto[], showNotification =
|
|||
type: NotificationType.Info,
|
||||
button: {
|
||||
text: $t('view_stack'),
|
||||
onClick: () => assetViewingStore.setAssetId(stack.primaryAssetId),
|
||||
onClick: () => navigate({ targetRoute: 'current', assetId: stack.primaryAssetId }),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
@ -405,10 +410,13 @@ export const stackAssets = async (assets: AssetResponseDto[], showNotification =
|
|||
asset.stack = index === 0 ? { id: stack.id, assetCount: stack.assets.length, primaryAssetId: asset.id } : null;
|
||||
}
|
||||
|
||||
return assets.slice(1).map((asset) => asset.id);
|
||||
return {
|
||||
stack,
|
||||
toDeleteIds: assets.slice(1).map((asset) => asset.id),
|
||||
};
|
||||
} catch (error) {
|
||||
handleError(error, $t('errors.failed_to_stack_assets'));
|
||||
return false;
|
||||
return { stack: undefined, toDeleteIds: [] };
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue