fix: gallery.yaml album order on homepage + stale settings cache (#391)
* fix: honour gallery.yaml order for homepage albums getStandaloneAlbums() filtered the Immich API album list but kept the API's own (creation/update) order, so reordering the albums list in gallery.yaml or the admin panel had no effect on the homepage. Sort by the config list's index instead. Fixes #352 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: serve fresh settings after admin save without restart getConfig() short-circuited on a per-worker in-memory cache in production. Admin saves invalidate that cache only in the worker that handles the API request; when Next.js renders pages in a different worker/process, its copy stayed stale until a container restart. Drop the in-memory config cache entirely and rebuild the config per call. Freshness comes from the existing mtime-checked YAML cache in loadYaml() — one statSync per file, negligible next to Immich API calls, and the same behaviour dev mode has always had. Fixes #351 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: ralksta <ralksta@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,7 +12,7 @@ vi.mock('../config', async () => {
|
||||
immich: { apiUrl: 'http://immich.test/api', apiKey: 'test-key' },
|
||||
authSecret: 'test-auth-secret-32-chars-long-min',
|
||||
albums: ['album-1', 'album-2'],
|
||||
standaloneAlbums: ['album-1'],
|
||||
standaloneAlbums: ['album-2', 'album-1'],
|
||||
subpages: [],
|
||||
albumOverrides: { 'album-1': 'Override Name' },
|
||||
albumDescriptions: {},
|
||||
@@ -78,6 +78,24 @@ describe('ImmichClient', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('getStandaloneAlbums()', () => {
|
||||
it('orders albums by gallery.yaml order, not Immich API order', async () => {
|
||||
// The Immich API returns albums in its own (creation/update) order;
|
||||
// the config lists album-2 first, so that must win on the homepage.
|
||||
mockFetch.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
headers: { get: () => 'application/json' },
|
||||
json: async () => [
|
||||
{ id: 'album-1', albumName: 'First in API', assetCount: 1 },
|
||||
{ id: 'album-2', albumName: 'Second in API', assetCount: 1 },
|
||||
],
|
||||
});
|
||||
|
||||
const albums = await immich.getStandaloneAlbums();
|
||||
expect(albums.map((a) => a.id)).toEqual(['album-2', 'album-1']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getAlbum()', () => {
|
||||
it('returns null for unallowed album IDs', async () => {
|
||||
const album = await immich.getAlbum('album-3');
|
||||
|
||||
Reference in New Issue
Block a user