Categorize pixels lenses without makes

This commit is contained in:
Sam Becker 2025-03-29 12:06:12 -05:00
parent b1bbd8935a
commit 88ef90fb38
2 changed files with 10 additions and 7 deletions

View File

@ -1,8 +1,8 @@
import { Photo } from '@/photo';
import { parameterize } from '@/utility/string';
import { formatAppleLensText, isLensMakeApple } from '../platforms/apple';
import { formatAppleLensText, isLensApple } from '../platforms/apple';
import { MISSING_FIELD } from '@/app/paths';
import { formatGoogleLensText, isLensMakeGoogle } from '../platforms/google';
import { formatGoogleLensText, isLensGoogle } from '../platforms/google';
const LENS_PLACEHOLDER: Lens = { make: 'Lens', model: 'Model' };
@ -88,13 +88,15 @@ export const lensFromPhoto = (
: fallback ?? LENS_PLACEHOLDER;
export const formatLensText = (
{ make, model: modelRaw }: Lens,
lens: Lens,
length:
'long' | // Unmodified make and model
'medium' | // Make and model, with modifiers removed
'short' // Model only
= 'medium',
) => {
const { make, model: modelRaw } = lens;
// Capture simple make without modifiers like 'Corporation' or 'Company'
const makeSimple = make?.match(/^(\S+)/)?.[1];
const doesModelStartWithMake = (
@ -102,9 +104,9 @@ export const formatLensText = (
modelRaw.toLocaleLowerCase().startsWith(makeSimple.toLocaleLowerCase())
);
const model = isLensMakeApple(make)
const model = isLensApple(lens)
? formatAppleLensText(modelRaw, length === 'medium')
: isLensMakeGoogle(make)
: isLensGoogle(lens)
? formatGoogleLensText(modelRaw, length === 'medium')
: modelRaw;

View File

@ -13,8 +13,9 @@ export const isCameraGoogle = ({ make }: Camera) =>
export const isLensMakeGoogle = (make?: string) =>
make?.toLocaleLowerCase() === MAKE_GOOGLE;
export const isLensGoogle = ({ make }: Lens) =>
isLensMakeGoogle(make);
export const isLensGoogle = ({ make, model }: Lens) =>
isLensMakeGoogle(make) ||
/^Pixel [0-9a-z]+/i.test(model);
export const formatGoogleLensText = (
model: string,