mirror of
https://github.com/immich-app/immich.git
synced 2026-03-12 21:42:54 -07: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);
|
||||
});
|
||||
|
||||
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
|
||||
it('ignores trashed assets when isTrashed is true', async () => {
|
||||
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.isFavorite, asset.isFavorite) ||
|
||||
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))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ export type Direction = 'earlier' | 'later';
|
||||
export type TimelineAsset = {
|
||||
id: string;
|
||||
ownerId: string;
|
||||
tags?: string[];
|
||||
ratio: number;
|
||||
thumbhash: string | null;
|
||||
localDateTime: TimelineDateTime;
|
||||
|
||||
@@ -170,6 +170,7 @@ export const toTimelineAsset = (unknownAsset: AssetResponseDto | TimelineAsset):
|
||||
return {
|
||||
id: assetResponse.id,
|
||||
ownerId: assetResponse.ownerId,
|
||||
tags: assetResponse.tags?.map((tag) => tag.id),
|
||||
ratio,
|
||||
thumbhash: assetResponse.thumbhash,
|
||||
localDateTime,
|
||||
|
||||
@@ -37,6 +37,7 @@ export const timelineAssetFactory = Sync.makeFactory<TimelineAsset>({
|
||||
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
|
||||
ownerId: Sync.each(() => faker.string.uuid()),
|
||||
tags: [],
|
||||
thumbhash: Sync.each(() => faker.string.alphanumeric(28)),
|
||||
localDateTime: Sync.each(() => fromISODateTimeUTCToObject(faker.date.past().toISOString())),
|
||||
fileCreatedAt: Sync.each(() => fromISODateTimeUTCToObject(faker.date.past().toISOString())),
|
||||
|
||||
Reference in New Issue
Block a user