From 16c58facc92e41d6acbcdf4820d3b70850e73a16 Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Mon, 31 Mar 2025 09:13:13 -0500 Subject: [PATCH] Always show all film simulations for fujis --- src/film/index.ts | 36 ++++++++++++++++++++++++++------- src/photo/form/PhotoForm.tsx | 3 ++- src/platforms/fujifilm/index.ts | 5 ++++- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/film/index.ts b/src/film/index.ts index 23882656..c1324fa5 100644 --- a/src/film/index.ts +++ b/src/film/index.ts @@ -9,11 +9,13 @@ import { absolutePathForFilmImage, } from '@/app/paths'; import { + FILM_SIMULATION_FORM_INPUT_OPTIONS, FujifilmSimulation, labelForFilm, } from '@/platforms/fujifilm/simulation'; import { formatCount } from '@/utility/string'; import { formatCountDescriptive } from '@/utility/string'; +import { AnnotatedTag } from '@/photo/form'; export type FilmSimulation = FujifilmSimulation; @@ -85,10 +87,30 @@ export const generateMetaForFilm = ( export const photoHasFilmData = (photo: Photo) => Boolean(photo.film); -export const convertFilmsForForm = (films: Films = []) => - sortFilms(films) - .map(({ film, count }) => ({ - value: film, - annotation: formatCount(count), - annotationAria: formatCountDescriptive(count), - })); +export const convertFilmsForForm = ( + _films: Films = [], + includeAllFujifilmSimulations?: boolean, +): AnnotatedTag[] => { + const films = includeAllFujifilmSimulations + ? FILM_SIMULATION_FORM_INPUT_OPTIONS.map(film => ({ + value: film.value, + } as AnnotatedTag)) + : []; + + _films.forEach(({ film, count }) => { + const index = films.findIndex(f => f.value === film); + const annotation = formatCount(count); + const annotationAria = formatCountDescriptive(count); + if (index !== -1) { + films[index] = { + ...films[index], + annotation, + annotationAria, + }; + } else { + films.push({ value: film, annotation, annotationAria }); + } + }); + + return films.sort((a, b) => a.value.localeCompare(b.value)); +}; diff --git a/src/photo/form/PhotoForm.tsx b/src/photo/form/PhotoForm.tsx index c0fdef5a..6b8e5524 100644 --- a/src/photo/form/PhotoForm.tsx +++ b/src/photo/form/PhotoForm.tsx @@ -44,6 +44,7 @@ import ApplyRecipeTitleGloballyCheckbox from './ApplyRecipesGloballyCheckbox'; import { convertFilmsForForm, Films, FilmSimulation } from '@/film'; import IconFavs from '@/components/icons/IconFavs'; import IconHidden from '@/components/icons/IconHidden'; +import { isMakeFujifilm } from '@/platforms/fujifilm'; const THUMBNAIL_SIZE = 300; @@ -328,7 +329,7 @@ export default function PhotoForm({ {FORM_METADATA_ENTRIES( convertTagsForForm(uniqueTags), convertRecipesForForm(uniqueRecipes), - convertFilmsForForm(uniqueFilms), + convertFilmsForForm(uniqueFilms, isMakeFujifilm(formData.make)), aiContent !== undefined, shouldStripGpsData, ) diff --git a/src/platforms/fujifilm/index.ts b/src/platforms/fujifilm/index.ts index 1fe6ad9c..858a7ba2 100644 --- a/src/platforms/fujifilm/index.ts +++ b/src/platforms/fujifilm/index.ts @@ -20,7 +20,10 @@ const BYTES_PER_TAG = 12; const BYTES_PER_TAG_VALUE = 4; export const isExifForFujifilm = (data: ExifData) => - data.tags?.Make === MAKE_FUJIFILM; + data.tags?.Make?.toLocaleUpperCase() === MAKE_FUJIFILM; + +export const isMakeFujifilm = (make?: string) => + make?.toLocaleUpperCase() === MAKE_FUJIFILM; export const parseFujifilmMakerNote = ( bytes: Buffer,