refactor(web): shared link key auth (#3855)

This commit is contained in:
Jason Rasmussen 2023-08-25 00:03:28 -04:00 committed by GitHub
parent 10c2bda3a9
commit 9bbef4a97b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 115 additions and 108 deletions

View file

@ -6,7 +6,6 @@
import { getAssetControlContext } from '../asset-select-control-bar.svelte';
export let filename = 'immich.zip';
export let sharedLinkKey: string | undefined = undefined;
export let menuItem = false;
const { getAssets, clearSelect } = getAssetControlContext();
@ -15,12 +14,12 @@
const assets = Array.from(getAssets());
if (assets.length === 1) {
clearSelect();
await downloadFile(assets[0], sharedLinkKey);
await downloadFile(assets[0]);
return;
}
clearSelect();
await downloadArchive(filename, { assetIds: assets.map((asset) => asset.id) }, sharedLinkKey);
await downloadArchive(filename, { assetIds: assets.map((asset) => asset.id) });
};
</script>

View file

@ -20,7 +20,7 @@
assetIdsDto: {
assetIds: Array.from(getAssets()).map((asset) => asset.id),
},
key: sharedLink.key,
key: api.getKey(),
});
for (const result of results) {

View file

@ -21,7 +21,6 @@
export let isSelectionMode = false;
export let viewport: Viewport;
export let singleSelect = false;
export let publicSharedKey: string | undefined = undefined;
export let assetStore: AssetStore;
export let assetInteractionStore: AssetInteractionStore;
@ -96,7 +95,7 @@
return;
}
assetViewingStore.setAssetId(asset.id, publicSharedKey);
assetViewingStore.setAssetId(asset.id);
};
const handleSelectGroup = (title: string, assets: AssetResponseDto[]) => dispatch('select', { title, assets });
@ -189,7 +188,6 @@
disabled={$assetStore.albumAssets.has(asset.id)}
thumbnailWidth={box.width}
thumbnailHeight={box.height}
{publicSharedKey}
/>
</div>
{/each}

View file

@ -23,7 +23,7 @@
export let assetStore: AssetStore;
export let assetInteractionStore: AssetInteractionStore;
export let removeAction: AssetAction | null = null;
export let publicSharedKey: string | undefined = undefined;
const { assetSelectionCandidates, assetSelectionStart, selectedGroup, selectedAssets, isMultiSelectState } =
assetInteractionStore;
const viewport: Viewport = { width: 0, height: 0 };
@ -97,7 +97,7 @@
const handlePrevious = async () => {
const previousAsset = await assetStore.getPreviousAssetId($viewingAsset.id);
if (previousAsset) {
assetViewingStore.setAssetId(previousAsset, publicSharedKey);
assetViewingStore.setAssetId(previousAsset);
}
return !!previousAsset;
@ -106,7 +106,7 @@
const handleNext = async () => {
const nextAsset = await assetStore.getNextAssetId($viewingAsset.id);
if (nextAsset) {
assetViewingStore.setAssetId(nextAsset, publicSharedKey);
assetViewingStore.setAssetId(nextAsset);
}
return !!nextAsset;
@ -349,7 +349,6 @@
bucketDate={bucket.bucketDate}
bucketHeight={bucket.bucketHeight}
{viewport}
{publicSharedKey}
/>
{/if}
</div>
@ -371,7 +370,6 @@
on:unarchived={({ detail: asset }) => handleAction(asset, AssetAction.UNARCHIVE)}
on:favorite={({ detail: asset }) => handleAction(asset, AssetAction.FAVORITE)}
on:unfavorite={({ detail: asset }) => handleAction(asset, AssetAction.UNFAVORITE)}
{publicSharedKey}
/>
{/if}
</Portal>