The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix(maps): marker thumbs from cached place photos load under the same request limit
Maurice106b748551f8
diff --git a/client/src/services/photoService.ts b/client/src/services/photoService.tsindex 860db5138..925329682 100644--- a/client/src/services/photoService.ts+++ b/client/src/services/photoService.ts@@ -114,10 +114,15 @@ export function fetchPhoto(cache.set(cacheKey, entry)callback?.(entry)notify(cacheKey, entry)- // Generate base64 thumb in background- void urlToBase64(photoId).then(thumb => {- if (thumb) { entry.thumbDataUrl = thumb; notifyThumb(cacheKey, thumb) }- })+ // Generate base64 thumb in background, under the same limit as the API path:+ // a list of a thousand saved places would otherwise ask for a thousand+ // pictures at once (#2559).+ void acquireRequestSlot()+ .then(() => urlToBase64(photoId))+ .then(thumb => {+ if (thumb) { entry.thumbDataUrl = thumb; notifyThumb(cacheKey, thumb) }+ })+ .finally(releaseRequestSlot)return}diff --git a/client/tests/unit/services/photoService.test.ts b/client/tests/unit/services/photoService.test.tsindex 12a43bebd..dff707cb5 100644--- a/client/tests/unit/services/photoService.test.ts+++ b/client/tests/unit/services/photoService.test.ts@@ -385,7 +385,7 @@ describe('fetchPhoto — stable proxy URL', () => {svc.onThumbReady('k', thumbFn);svc.fetchPhoto('k', '/api/maps/place-photo/abc123', undefined, undefined, undefined, cb);- // Synchronous — no request slot, no API call.+ // The entry is there synchronously, without an API call.expect(mockPlacePhoto).not.toHaveBeenCalled();expect(cb).toHaveBeenCalledWith({ photoUrl: '/api/maps/place-photo/abc123', thumbDataUrl: null });@@ -454,6 +454,40 @@ describe('fetchPhoto — concurrency limiter', () => {expect(mockPlacePhoto).toHaveBeenCalledTimes(6);});++ it('FE-COMP-PHOTO-026: proxy URL thumbs share the same limit, so a big list does not load every picture at once (#2559)', async () => {+ // Images that only load when the test says so.+ const pending: Array<() => void> = [];+ Object.defineProperty(HTMLImageElement.prototype, 'src', {+ configurable: true,+ set(url: string) {+ (this as HTMLImageElement & { _src: string })._src = url;+ pending.push(() => { if (typeof this.onload === 'function') this.onload(new Event('load')); });+ },+ get() {+ return (this as HTMLImageElement & { _src: string })._src ?? '';+ },+ });++ for (let i = 0; i < 12; i += 1) {+ svc.fetchPhoto(`p${i}`, `/api/maps/place-photo/p${i}`);+ }+ await flush();++ // The entries are there at once, only the picture downloads wait their turn.+ expect(svc.getCached('p11')?.photoUrl).toBe('/api/maps/place-photo/p11');+ expect(pending).toHaveLength(5);++ pending.splice(0, 2).forEach((load) => load());+ await flush();+ expect(pending).toHaveLength(5);++ while (pending.length > 0) {+ pending.splice(0).forEach((load) => load());+ await flush();+ }+ expect(Object.keys(svc.getAllThumbs())).toHaveLength(12);+ });});// ==============================================================================