mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 10:24:05 +00:00
fix(journey): select all takes every photo in the range and imports keep their order
The photo picker's Select all took only the pages already loaded, 50 at a time, and replaced whatever had been picked on another tab. It now loads the rest of a day, trip or date-range search before selecting (cancelled by closing the picker or switching tab), adds to earlier picks, and Deselect all only clears what is in view. Add stays disabled until that loading is done. The whole-library tab keeps selecting what is loaded and shows the count as "N+". A date-filtered Immich search stopped at 1,000 photos without a word, because its page budget was absolute; it is now relative to the page asked for, with an absolute ceiling of 270 raw pages sized so the picker's deepest page still gets a full answer. Adds go out in batches of 500 ids, under the JSON body limit, and each batch is sent oldest first, so photos land in an entry in the order they were taken. When a later batch fails, the photos already saved are counted and the journey reloads while the error still shows, through one hook for desktop and phone. After a provider add, the capture-time lookup runs at most four at a time per user, shared by all of that user's batches. When it fills a row, a journey:photos:updated event reloads open journeys once per batch, from the REST routes and the MCP add tool alike. Device uploads, which arrive one file per request, get the same lookup without the event. Addresses discussion #1587.
This commit is contained in:
@@ -982,6 +982,52 @@ describe('Immich searchPhotos pagination pass-through', () => {
|
||||
expect(res.body.hasMore).toBe(false);
|
||||
});
|
||||
|
||||
it('IMMICH-094: POST /search reaches a date-filtered page past the twentieth at the picker page size (#1587)', async () => {
|
||||
const { user } = createUser(testDb);
|
||||
setImmichCredentials(testDb, user.id, 'https://immich.example.com', 'test-api-key');
|
||||
|
||||
// Every raw page is 200 photos of the searched day, so answered page 21
|
||||
// needs raw pages 1 to 21. The old flat budget of 20 answered it empty with
|
||||
// hasMore false, which is where a trip stopped without a word.
|
||||
const previous = vi.mocked(safeFetch).getMockImplementation();
|
||||
vi.mocked(safeFetch).mockClear();
|
||||
vi.mocked(safeFetch).mockImplementation(async (_url: unknown, init?: { body?: unknown }) => {
|
||||
const rawPage = JSON.parse(String(init?.body ?? '{}')).page as number;
|
||||
return {
|
||||
ok: true, status: 200,
|
||||
headers: { get: () => null },
|
||||
json: () => Promise.resolve({
|
||||
assets: {
|
||||
items: Array.from({ length: 200 }, (_, i) => ({
|
||||
id: `deep-${rawPage}-${i}`,
|
||||
fileCreatedAt: '2024-06-01T10:00:00.000Z',
|
||||
localDateTime: '2024-06-01T12:00:00.000Z',
|
||||
})),
|
||||
},
|
||||
}),
|
||||
body: null,
|
||||
} as never;
|
||||
});
|
||||
|
||||
let res: request.Response;
|
||||
try {
|
||||
res = await request(app)
|
||||
.post(`${IMMICH}/search`)
|
||||
.set('Cookie', authCookie(user.id))
|
||||
.send({ from: '2024-06-01', to: '2024-06-01', page: 21, size: 200 });
|
||||
} finally {
|
||||
if (previous) vi.mocked(safeFetch).mockImplementation(previous);
|
||||
}
|
||||
|
||||
expect(res.status).toBe(200);
|
||||
expect(res.body.assets).toHaveLength(200);
|
||||
expect(res.body.assets[0].id).toMatch(/^deep-21-/);
|
||||
expect(res.body.hasMore).toBe(true);
|
||||
expect(vi.mocked(safeFetch)).toHaveBeenCalledTimes(21);
|
||||
const sizes = vi.mocked(safeFetch).mock.calls.map(c => JSON.parse(String((c[1] as { body?: unknown }).body)).size);
|
||||
expect(new Set(sizes)).toEqual(new Set([200]));
|
||||
});
|
||||
|
||||
it('IMMICH-093 — POST /search requests timeline visibility so Immich v3 never returns hidden assets (#1474)', async () => {
|
||||
const { user } = createUser(testDb);
|
||||
setImmichCredentials(testDb, user.id, 'https://immich.example.com', 'test-api-key');
|
||||
|
||||
Reference in New Issue
Block a user