mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
PR fix
This commit is contained in:
parent
0a3dc85676
commit
61ca2e9155
1 changed files with 18 additions and 13 deletions
|
|
@ -48,18 +48,6 @@
|
||||||
})),
|
})),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const expiresAt = DateTime.fromISO(editingLink?.expiresAt);
|
|
||||||
const createdAt = DateTime.fromISO(editingLink?.createdAt);
|
|
||||||
|
|
||||||
const remainingMs = expiresAt.toMillis() - createdAt.toMillis();
|
|
||||||
let selectedOption = expiredDateOptions[0];
|
|
||||||
|
|
||||||
for (const option of expiredDateOptions) {
|
|
||||||
if (option.value <= remainingMs) {
|
|
||||||
selectedOption = option;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let shareType = $derived(albumId ? SharedLinkType.Album : SharedLinkType.Individual);
|
let shareType = $derived(albumId ? SharedLinkType.Album : SharedLinkType.Individual);
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
|
|
@ -81,6 +69,23 @@
|
||||||
|
|
||||||
albumId = editingLink.album?.id;
|
albumId = editingLink.album?.id;
|
||||||
assetIds = editingLink.assets.map(({ id }) => id);
|
assetIds = editingLink.assets.map(({ id }) => id);
|
||||||
|
|
||||||
|
const expiresAt = editingLink.expiresAt ? DateTime.fromISO(editingLink.expiresAt) : DateTime.fromMillis(0);
|
||||||
|
const createdAt = DateTime.fromISO(editingLink.createdAt);
|
||||||
|
|
||||||
|
if (expiresAt) {
|
||||||
|
const remainingMs = expiresAt.toMillis() - createdAt.toMillis();
|
||||||
|
|
||||||
|
const bestOption = expiredDateOptions.reduce((best, option) => {
|
||||||
|
const diff = Math.abs(option.value - remainingMs);
|
||||||
|
const bestDiff = Math.abs(best.value - remainingMs);
|
||||||
|
return diff < bestDiff ? option : best;
|
||||||
|
});
|
||||||
|
|
||||||
|
expirationOption = bestOption.value;
|
||||||
|
} else {
|
||||||
|
expirationOption = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleCreateSharedLink = async () => {
|
const handleCreateSharedLink = async () => {
|
||||||
|
|
@ -194,7 +199,7 @@
|
||||||
|
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
<SettingSelect
|
<SettingSelect
|
||||||
bind:value={selectedOption.value}
|
bind:value={expirationOption}
|
||||||
options={expiredDateOptions}
|
options={expiredDateOptions}
|
||||||
label={$t('expire_after')}
|
label={$t('expire_after')}
|
||||||
disabled={editingLink && !shouldChangeExpirationTime}
|
disabled={editingLink && !shouldChangeExpirationTime}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue