Skip to content

Commit 2b57290

Browse files
committed
fix: photo file naming and favorites photo loading
- Use 'wiki' suffix instead of 'wikipedia' in photo filenames to match getWikiPhotoPath - Add photo URLs to favorites list (load from augmentation data)
1 parent a45640d commit 2b57290

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

server/src/services/augmentation.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,8 +1077,10 @@ export const augmentationService = {
10771077
}
10781078

10791079
// Determine file extension and path
1080+
// Use 'wiki' instead of 'wikipedia' to match getWikiPhotoPath convention
10801081
const ext = photoUrl.toLowerCase().includes('.png') ? 'png' : 'jpg';
1081-
const photoPath = path.join(PHOTOS_DIR, `${personId}-${platform}.${ext}`);
1082+
const suffix = platform === 'wikipedia' ? 'wiki' : platform;
1083+
const photoPath = path.join(PHOTOS_DIR, `${personId}-${suffix}.${ext}`);
10821084

10831085
// Download the photo
10841086
console.log(`[augment] Downloading photo from ${photoUrl}`);

server/src/services/favorites.service.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,16 @@ async function listDbFavoritesSqlite(
250250
const deathYear = row.death_date?.match(/\d{4}/)?.at(0) ?? '';
251251
const lifespan = birthYear || deathYear ? `${birthYear}-${deathYear}` : '';
252252

253+
// Get photo URL from augmentation data
254+
const augmentation = augmentationService.getAugmentation(personId);
255+
const photoUrl = getPhotoUrl(personId, augmentation || undefined);
256+
253257
favorites.push({
254258
personId,
255259
externalId: row.external_id ?? undefined, // FamilySearch ID for display
256260
name: row.display_name,
257261
lifespan,
258-
photoUrl: undefined, // Skip photo lookup for speed - lazy load when needed
262+
photoUrl,
259263
favorite: {
260264
isFavorite: true,
261265
whyInteresting: row.why_interesting ?? '',
@@ -622,12 +626,16 @@ export const favoritesService = {
622626
const deathYear = row.death_date?.match(/\d{4}/)?.at(0) ?? '';
623627
const lifespan = birthYear || deathYear ? `${birthYear}-${deathYear}` : '';
624628

629+
// Get photo URL from augmentation data
630+
const augmentation = augmentationService.getAugmentation(personId);
631+
const photoUrl = getPhotoUrl(personId, augmentation || undefined);
632+
625633
personMap.set(personId, {
626634
personId,
627635
externalId: row.external_id ?? undefined, // FamilySearch ID for display
628636
name: row.display_name,
629637
lifespan,
630-
photoUrl: undefined, // Skip photo lookup for speed - can be lazy loaded
638+
photoUrl,
631639
favorite: {
632640
isFavorite: true,
633641
whyInteresting: row.why_interesting ?? '',

0 commit comments

Comments
 (0)