Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
);
}
Expand Down
1 change: 1 addition & 0 deletions web/src/lib/managers/timeline-manager/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions web/src/lib/utils/timeline-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions web/src/test-data/factories/asset-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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())),
Expand Down
Loading