mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
fix(web): prevent unrelated assets from appearing in tag view (#26816)
This commit is contained in:
@@ -286,6 +286,17 @@ describe('TimelineManager', () => {
|
|||||||
expect(timelineManager.assetCount).toEqual(1);
|
expect(timelineManager.assetCount).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('ignores new assets that do not match the tag filter', async () => {
|
||||||
|
await timelineManager.updateOptions({ tagId: 'tag-1' });
|
||||||
|
|
||||||
|
const matching = deriveLocalDateTimeFromFileCreatedAt(timelineAssetFactory.build({ tags: ['tag-1'] }));
|
||||||
|
const unrelated = deriveLocalDateTimeFromFileCreatedAt(timelineAssetFactory.build({ tags: ['tag-2'] }));
|
||||||
|
|
||||||
|
timelineManager.upsertAssets([matching, unrelated]);
|
||||||
|
|
||||||
|
expect(await getAssets(timelineManager)).toEqual([matching]);
|
||||||
|
});
|
||||||
|
|
||||||
// disabled due to the wasm Justified Layout import
|
// disabled due to the wasm Justified Layout import
|
||||||
it('ignores trashed assets when isTrashed is true', async () => {
|
it('ignores trashed assets when isTrashed is true', async () => {
|
||||||
const asset = deriveLocalDateTimeFromFileCreatedAt(timelineAssetFactory.build({ isTrashed: false }));
|
const asset = deriveLocalDateTimeFromFileCreatedAt(timelineAssetFactory.build({ isTrashed: false }));
|
||||||
|
|||||||
@@ -596,6 +596,7 @@ export class TimelineManager extends VirtualScrollManager {
|
|||||||
isMismatched(this.#options.visibility, asset.visibility) ||
|
isMismatched(this.#options.visibility, asset.visibility) ||
|
||||||
isMismatched(this.#options.isFavorite, asset.isFavorite) ||
|
isMismatched(this.#options.isFavorite, asset.isFavorite) ||
|
||||||
isMismatched(this.#options.isTrashed, asset.isTrashed) ||
|
isMismatched(this.#options.isTrashed, asset.isTrashed) ||
|
||||||
|
(this.#options.tagId && asset.tags && !asset.tags.includes(this.#options.tagId)) ||
|
||||||
(this.#options.assetFilter !== undefined && !this.#options.assetFilter.has(asset.id))
|
(this.#options.assetFilter !== undefined && !this.#options.assetFilter.has(asset.id))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export type Direction = 'earlier' | 'later';
|
|||||||
export type TimelineAsset = {
|
export type TimelineAsset = {
|
||||||
id: string;
|
id: string;
|
||||||
ownerId: string;
|
ownerId: string;
|
||||||
|
tags?: string[];
|
||||||
ratio: number;
|
ratio: number;
|
||||||
thumbhash: string | null;
|
thumbhash: string | null;
|
||||||
localDateTime: TimelineDateTime;
|
localDateTime: TimelineDateTime;
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ export const toTimelineAsset = (unknownAsset: AssetResponseDto | TimelineAsset):
|
|||||||
return {
|
return {
|
||||||
id: assetResponse.id,
|
id: assetResponse.id,
|
||||||
ownerId: assetResponse.ownerId,
|
ownerId: assetResponse.ownerId,
|
||||||
|
tags: assetResponse.tags?.map((tag) => tag.id),
|
||||||
ratio,
|
ratio,
|
||||||
thumbhash: assetResponse.thumbhash,
|
thumbhash: assetResponse.thumbhash,
|
||||||
localDateTime,
|
localDateTime,
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ export const timelineAssetFactory = Sync.makeFactory<TimelineAsset>({
|
|||||||
id: Sync.each(() => faker.string.uuid()),
|
id: Sync.each(() => faker.string.uuid()),
|
||||||
ratio: Sync.each((i) => 0.2 + ((i * 0.618_034) % 3.8)), // deterministic random float between 0.2 and 4.0
|
ratio: Sync.each((i) => 0.2 + ((i * 0.618_034) % 3.8)), // deterministic random float between 0.2 and 4.0
|
||||||
ownerId: Sync.each(() => faker.string.uuid()),
|
ownerId: Sync.each(() => faker.string.uuid()),
|
||||||
|
tags: [],
|
||||||
thumbhash: Sync.each(() => faker.string.alphanumeric(28)),
|
thumbhash: Sync.each(() => faker.string.alphanumeric(28)),
|
||||||
localDateTime: Sync.each(() => fromISODateTimeUTCToObject(faker.date.past().toISOString())),
|
localDateTime: Sync.each(() => fromISODateTimeUTCToObject(faker.date.past().toISOString())),
|
||||||
fileCreatedAt: Sync.each(() => fromISODateTimeUTCToObject(faker.date.past().toISOString())),
|
fileCreatedAt: Sync.each(() => fromISODateTimeUTCToObject(faker.date.past().toISOString())),
|
||||||
|
|||||||
Reference in New Issue
Block a user