From fed508d5b7a5b8bed69d894a542eacee98c50fdb Mon Sep 17 00:00:00 2001 From: Linus Rath Date: Mon, 9 Mar 2026 21:08:45 +0100 Subject: [PATCH] fix: demo-only features for gender inference and custom avatars in development --- components/ui/avatar.tsx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/components/ui/avatar.tsx b/components/ui/avatar.tsx index 1a60d166..3d1f42cb 100644 --- a/components/ui/avatar.tsx +++ b/components/ui/avatar.tsx @@ -4,6 +4,8 @@ import { useState } from "react"; import { cn } from "@/lib/utils"; import { useSettingsStore } from "@/stores/settings-store"; +const IS_DEV = process.env.NODE_ENV !== "production"; + // Personal email domains where the favicon is the mail provider logo, not the sender const PERSONAL_DOMAINS = new Set([ "gmail.com", "googlemail.com", "outlook.com", "hotmail.com", "live.com", @@ -24,24 +26,24 @@ function emailHash(email: string): number { return Math.abs(hash); } -// Common first names to infer gender for portrait selection -const FEMALE_NAMES = new Set([ +// Dev-only: common first names to infer gender for demo portrait selection +const FEMALE_NAMES: Set = IS_DEV ? new Set([ "alice", "emily", "sarah", "priya", "carol", "anna", "maria", "emma", "olivia", "sophia", "isabella", "mia", "charlotte", "amelia", "harper", "ella", "grace", "chloe", "luna", "lily", "zoey", "hannah", "nora", "riley", "elena", "maya", "claire", "victoria", "natalie", "rachel", "jessica", "jennifer", "lisa", "karen", "nancy", "betty", "sandra", "ashley", "margaret", "dorothy", "julia", "laura", "susan", "andrea", "diana", "marie", "sophie", -]); +]) : new Set(); -const MALE_NAMES = new Set([ +const MALE_NAMES: Set = IS_DEV ? new Set([ "bob", "marcus", "alex", "david", "james", "john", "robert", "michael", "william", "richard", "joseph", "thomas", "charles", "daniel", "matthew", "anthony", "mark", "steven", "paul", "andrew", "kevin", "brian", "george", "timothy", "jason", "ryan", "jacob", "gary", "eric", "peter", "frank", "samuel", "benjamin", "henry", "patrick", "jack", "noah", "liam", "oliver", "lucas", "ethan", "mason", "logan", "leo", "max", "oscar", "hugo", -]); +]) : new Set(); function inferGender(name: string | undefined, hash: number): "women" | "men" { if (name) { @@ -52,19 +54,20 @@ function inferGender(name: string | undefined, hash: number): "women" | "men" { return hash % 2 === 0 ? "women" : "men"; } -// Custom avatar URLs for specific demo senders (e.g. newsletters with custom logos) -const CUSTOM_AVATARS: Record = { +// Dev-only: custom avatar URLs for specific demo senders +const CUSTOM_AVATARS: Record = IS_DEV ? { "newsletter@launchweekly.com": "https://img.freepik.com/premium-vector/swoosh-letter-lw-logo-design-business-company-identity-water-wave-lw-logo-with-modern-trendy_754537-799.jpg?w=360", "hello@launchpad.example": "https://img.freepik.com/premium-vector/swoosh-letter-lw-logo-design-business-company-identity-water-wave-lw-logo-with-modern-trendy_754537-799.jpg?w=360", "news@techdigest.example": "https://img.freepik.com/premium-vector/technology-letter-t-logo-design-template_125964-1249.jpg?w=360", "alice@example.com": "https://randomuser.me/api/portraits/thumb/women/44.jpg", "bob@example.org": "https://randomuser.me/api/portraits/thumb/men/32.jpg", "carol@example.com": "https://randomuser.me/api/portraits/thumb/women/68.jpg", -}; +} : {}; -// For personal-domain emails, deterministically pick a randomuser.me portrait. +// Dev-only: for personal-domain emails, deterministically pick a randomuser.me portrait. // Returns null for ~30% of addresses so not everyone has a photo. function getProfilePictureUrl(email: string, domain: string, name?: string): string | null { + if (!IS_DEV) return null; if (!PERSONAL_DOMAINS.has(domain)) return null; const h = emailHash(email); if (h % 10 < 3) return null; // ~30% get no photo