Don't return trashed assets

This commit is contained in:
Alan Grainger
2024-10-29 19:22:18 +01:00
parent 10633942c1
commit 07a1904b9d
4 changed files with 28 additions and 5 deletions
+11 -1
View File
@@ -1,4 +1,5 @@
import { Asset, AssetType, ImageSize, SharedLink } from './types'
import dayjs from 'dayjs'
class Immich {
/**
@@ -29,7 +30,16 @@ class Immich {
*/
async getShareByKey (key: string) {
const res = (await this.request('/shared-links') || []) as SharedLink[]
return res?.find(x => x.key === key)
const link = res.find(x => x.key === key)
if (link) {
// Filter assets to exclude trashed assets
link.assets = link.assets.filter(x => !x.isTrashed)
if (link.expiresAt && dayjs(link.expiresAt) < dayjs()) {
// This link has expired
} else {
return link
}
}
}
/**
+3 -1
View File
@@ -6,11 +6,13 @@ export enum AssetType {
export interface Asset {
id: string;
type: AssetType;
isTrashed: boolean;
}
export interface SharedLink {
key: string;
assets: Asset[]
assets: Asset[];
expiresAt: string | null;
}
export enum ImageSize {