frontend: route all photo queries through sidecar timeline proxy

- listPhotos → /api/sidecar/timeline (was /photos)
- countPhotos → /api/sidecar/timeline (was /photos)
- hasPhotosMatching → /api/sidecar/timeline (was /photos)
- Sidecar handler forwards X-Count header for countPhotos()
- Sidecar adjusts X-Count to reflect post-filtered count
This commit is contained in:
2026-06-06 20:17:13 +02:00
parent 7df1c04c0f
commit 14a1b4e54e
2 changed files with 9 additions and 3 deletions

View File

@@ -39,6 +39,10 @@ func handlePhotos(pp *ppClient) gin.HandlerFunc {
// If the user has no BasePath (admin/empty), return as-is.
if basePath == "" {
// Forward PhotoPrism's X-Count header for countPhotos().
if count := resp.Header.Get("X-Count"); count != "" {
c.Header("X-Count", count)
}
c.JSON(http.StatusOK, photos)
return
}
@@ -62,6 +66,8 @@ func handlePhotos(pp *ppClient) gin.HandlerFunc {
}
}
// Forward X-Count header adjusted to the filtered count.
c.Header("X-Count", itoa(len(filtered)))
c.JSON(http.StatusOK, filtered)
}
}

View File

@@ -144,7 +144,7 @@ export interface ListPhotosParams {
}
export async function listPhotos(params: ListPhotosParams = {}): Promise<PpPhoto[]> {
const { data } = await http.get<PpPhoto[]>('/photos', {
const { data } = await http.get<PpPhoto[]>('/api/sidecar/timeline', {
params: {
count: 60,
offset: 0,
@@ -260,7 +260,7 @@ export async function listPhotosAround(p: AroundParams): Promise<PpPhoto[]> {
*/
export async function countPhotos(q: string, opts: { merged?: boolean } = {}): Promise<number> {
const merged = opts.merged ?? false;
const resp = await http.get<PpPhoto[]>('/photos', {
const resp = await http.get<PpPhoto[]>('/api/sidecar/timeline', {
params: { count: 10000, offset: 0, merged, q }
});
// PhotoPrism's `X-Count` header counts SQL file rows (one row per
@@ -636,7 +636,7 @@ export async function aggregateKeywords(): Promise<AggregatedKeyword[]> {
}
async function hasPhotosMatching(q: string): Promise<boolean> {
const resp = await http.get<PpPhoto[]>('/photos', {
const resp = await http.get<PpPhoto[]>('/api/sidecar/timeline', {
params: { count: 1, offset: 0, q }
});
return Array.isArray(resp.data) && resp.data.length > 0;