mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
fix(web): prevent fetching asset info twice (#8486)
This commit is contained in:
parent
0529076ed7
commit
66650f5944
8 changed files with 47 additions and 61 deletions
|
|
@ -62,7 +62,7 @@
|
|||
|
||||
let reactions: ActivityResponseDto[] = [];
|
||||
|
||||
const { setAssetId } = assetViewingStore;
|
||||
const { setAsset } = assetViewingStore;
|
||||
const {
|
||||
restartProgress: restartSlideshowProgress,
|
||||
stopProgress: stopSlideshowProgress,
|
||||
|
|
@ -193,7 +193,7 @@
|
|||
slideshowStateUnsubscribe = slideshowState.subscribe((value) => {
|
||||
if (value === SlideshowState.PlaySlideshow) {
|
||||
slideshowHistory.reset();
|
||||
slideshowHistory.queue(asset.id);
|
||||
slideshowHistory.queue(asset);
|
||||
handlePromiseError(handlePlaySlideshow());
|
||||
} else if (value === SlideshowState.StopSlideshow) {
|
||||
handlePromiseError(handleStopSlideshow());
|
||||
|
|
@ -203,7 +203,7 @@
|
|||
shuffleSlideshowUnsubscribe = slideshowNavigation.subscribe((value) => {
|
||||
if (value === SlideshowNavigation.Shuffle) {
|
||||
slideshowHistory.reset();
|
||||
slideshowHistory.queue(asset.id);
|
||||
slideshowHistory.queue(asset);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -278,9 +278,9 @@
|
|||
return;
|
||||
}
|
||||
|
||||
slideshowHistory.queue(asset.id);
|
||||
slideshowHistory.queue(asset);
|
||||
|
||||
await setAssetId(asset.id);
|
||||
setAsset(asset);
|
||||
$restartSlideshowProgress = true;
|
||||
};
|
||||
|
||||
|
|
@ -299,9 +299,7 @@
|
|||
|
||||
if ($slideshowState === SlideshowState.PlaySlideshow && assetStore) {
|
||||
const hasNext =
|
||||
order === 'previous'
|
||||
? await assetStore.getPreviousAssetId(asset.id)
|
||||
: await assetStore.getNextAssetId(asset.id);
|
||||
order === 'previous' ? await assetStore.getPreviousAsset(asset.id) : await assetStore.getNextAsset(asset.id);
|
||||
if (hasNext) {
|
||||
$restartSlideshowProgress = true;
|
||||
} else {
|
||||
|
|
@ -441,8 +439,8 @@
|
|||
|
||||
let assetViewerHtmlElement: HTMLElement;
|
||||
|
||||
const slideshowHistory = new SlideshowHistory((assetId: string) => {
|
||||
handlePromiseError(setAssetId(assetId));
|
||||
const slideshowHistory = new SlideshowHistory((asset) => {
|
||||
setAsset(asset);
|
||||
$restartSlideshowProgress = true;
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -80,17 +80,13 @@
|
|||
});
|
||||
}
|
||||
|
||||
const assetClickHandler = async (
|
||||
asset: AssetResponseDto,
|
||||
assetsInDateGroup: AssetResponseDto[],
|
||||
groupTitle: string,
|
||||
) => {
|
||||
const assetClickHandler = (asset: AssetResponseDto, assetsInDateGroup: AssetResponseDto[], groupTitle: string) => {
|
||||
if (isSelectionMode || $isMultiSelectState) {
|
||||
assetSelectHandler(asset, assetsInDateGroup, groupTitle);
|
||||
return;
|
||||
}
|
||||
|
||||
await assetViewingStore.setAssetId(asset.id);
|
||||
assetViewingStore.setAsset(asset);
|
||||
};
|
||||
|
||||
const handleSelectGroup = (title: string, assets: AssetResponseDto[]) => dispatch('select', { title, assets });
|
||||
|
|
|
|||
|
|
@ -137,26 +137,22 @@
|
|||
}
|
||||
|
||||
const handlePrevious = async () => {
|
||||
const previousAsset = await assetStore.getPreviousAssetId($viewingAsset.id);
|
||||
const previousAsset = await assetStore.getPreviousAsset($viewingAsset.id);
|
||||
|
||||
if (previousAsset) {
|
||||
const preloadId = await assetStore.getPreviousAssetId(previousAsset);
|
||||
preloadId
|
||||
? await assetViewingStore.setAssetId(previousAsset, [preloadId])
|
||||
: await assetViewingStore.setAssetId(previousAsset);
|
||||
const preloadAsset = await assetStore.getPreviousAsset(previousAsset.id);
|
||||
assetViewingStore.setAsset(previousAsset, preloadAsset ? [preloadAsset] : []);
|
||||
}
|
||||
|
||||
return !!previousAsset;
|
||||
};
|
||||
|
||||
const handleNext = async () => {
|
||||
const nextAsset = await assetStore.getNextAssetId($viewingAsset.id);
|
||||
const nextAsset = await assetStore.getNextAsset($viewingAsset.id);
|
||||
|
||||
if (nextAsset) {
|
||||
const preloadId = await assetStore.getNextAssetId(nextAsset);
|
||||
preloadId
|
||||
? await assetViewingStore.setAssetId(nextAsset, [preloadId])
|
||||
: await assetViewingStore.setAssetId(nextAsset);
|
||||
const preloadAsset = await assetStore.getNextAsset(nextAsset.id);
|
||||
assetViewingStore.setAsset(nextAsset, preloadAsset ? [preloadAsset] : []);
|
||||
}
|
||||
|
||||
return !!nextAsset;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue