From c6a139d88d0aa7dc0fb56c8670e9ebbea73bc18d Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Wed, 17 Sep 2025 15:42:23 +0200 Subject: [PATCH] Rename Lovers -> Profiles --- backend/api/src/app.ts | 8 ++++---- backend/api/src/compatible-profiles.ts | 14 +++++++------- backend/api/src/get-profiles.ts | 6 +++--- backend/api/src/ship-profiles.ts | 2 +- backend/shared/src/love/supabase.ts | 4 ++-- common/src/api/schema.ts | 6 +++--- common/src/api/zod-types.ts | 6 +++--- common/src/filters.ts | 2 +- web/components/browse-matches-button.tsx | 22 +++++++++++----------- web/components/profiles/profiles-home.tsx | 22 +++++++++++----------- web/hooks/use-profiles.ts | 4 ++-- 11 files changed, 48 insertions(+), 48 deletions(-) diff --git a/backend/api/src/app.ts b/backend/api/src/app.ts index b00514f8..6b383657 100644 --- a/backend/api/src/app.ts +++ b/backend/api/src/app.ts @@ -9,7 +9,7 @@ import {log} from 'shared/monitoring/log' import {metrics} from 'shared/monitoring/metrics' import {banUser} from './ban-user' import {blockUser, unblockUser} from './block-user' -import {getCompatibleLoversHandler} from './compatible-profiles' +import {getCompatibleProfilesHandler} from './compatible-profiles' import {createComment} from './create-comment' import {createCompatibilityQuestion} from './create-compatibility-question' import {createLover} from './create-lover' @@ -31,7 +31,7 @@ import {removePinnedPhoto} from './remove-pinned-photo' import {report} from './report' import {searchLocation} from './search-location' import {searchNearCity} from './search-near-city' -import {shipLovers} from './ship-profiles' +import {shipProfiles} from './ship-profiles' import {starLover} from './star-lover' import {updateLover} from './update-lover' import {updateMe} from './update-me' @@ -142,7 +142,7 @@ const handlers: { [k in APIPath]: APIHandler } = { 'me/delete': deleteMe, 'update-lover': updateLover, 'like-lover': likeLover, - 'ship-profiles': shipLovers, + 'ship-profiles': shipProfiles, 'get-likes-and-ships': getLikesAndShips, 'has-free-like': hasFreeLike, 'star-lover': starLover, @@ -153,7 +153,7 @@ const handlers: { [k in APIPath]: APIHandler } = { 'create-comment': createComment, 'hide-comment': hideComment, 'create-compatibility-question': createCompatibilityQuestion, - 'compatible-profiles': getCompatibleLoversHandler, + 'compatible-profiles': getCompatibleProfilesHandler, 'search-location': searchLocation, 'search-near-city': searchNearCity, 'create-private-user-message': createPrivateUserMessage, diff --git a/backend/api/src/compatible-profiles.ts b/backend/api/src/compatible-profiles.ts index 393b61c0..cabe571e 100644 --- a/backend/api/src/compatible-profiles.ts +++ b/backend/api/src/compatible-profiles.ts @@ -4,17 +4,17 @@ import { getCompatibilityScore } from 'common/love/compatibility-score' import { getLover, getCompatibilityAnswers, - getGenderCompatibleLovers, + getGenderCompatibleProfiles, } from 'shared/love/supabase' import { log } from 'shared/utils' -export const getCompatibleLoversHandler: APIHandler< +export const getCompatibleProfilesHandler: APIHandler< 'compatible-profiles' > = async (props) => { - return getCompatibleLovers(props.userId) + return getCompatibleProfiles(props.userId) } -export const getCompatibleLovers = async (userId: string) => { +export const getCompatibleProfiles = async (userId: string) => { const lover = await getLover(userId) log('got lover', { @@ -25,7 +25,7 @@ export const getCompatibleLovers = async (userId: string) => { if (!lover) throw new APIError(404, 'Lover not found') - const profiles = await getGenderCompatibleLovers(lover) + const profiles = await getGenderCompatibleProfiles(lover) const loverAnswers = await getCompatibilityAnswers([ userId, @@ -47,7 +47,7 @@ export const getCompatibleLovers = async (userId: string) => { ) ) - const sortedCompatibleLovers = sortBy( + const sortedCompatibleProfiles = sortBy( profiles, (l) => loverCompatibilityScores[l.user_id].score ).reverse() @@ -55,7 +55,7 @@ export const getCompatibleLovers = async (userId: string) => { return { status: 'success', lover, - compatibleLovers: sortedCompatibleLovers, + compatibleProfiles: sortedCompatibleProfiles, loverCompatibilityScores, } } diff --git a/backend/api/src/get-profiles.ts b/backend/api/src/get-profiles.ts index 30d32586..72022ca7 100644 --- a/backend/api/src/get-profiles.ts +++ b/backend/api/src/get-profiles.ts @@ -2,7 +2,7 @@ import {type APIHandler} from 'api/helpers/endpoint' import {convertRow} from 'shared/love/supabase' import {createSupabaseDirectClient} from 'shared/supabase/init' import {from, join, limit, orderBy, renderSql, select, where,} from 'shared/supabase/sql-builder' -import {getCompatibleLovers} from 'api/compatible-profiles' +import {getCompatibleProfiles} from 'api/compatible-profiles' import {intersection} from 'lodash' import {MAX_INT, MIN_INT} from "common/constants"; @@ -59,8 +59,8 @@ export const loadProfiles = async (props: profileQueryType) => { throw Error('Incompatible with user ID') } - const {compatibleLovers} = await getCompatibleLovers(compatibleWithUserId) - const profiles = compatibleLovers.filter( + const {compatibleProfiles} = await getCompatibleProfiles(compatibleWithUserId) + const profiles = compatibleProfiles.filter( (l) => (!name || l.user.name.toLowerCase().includes(name.toLowerCase())) && (!genders || genders.includes(l.gender)) && diff --git a/backend/api/src/ship-profiles.ts b/backend/api/src/ship-profiles.ts index 3f61ca76..65a0a40d 100644 --- a/backend/api/src/ship-profiles.ts +++ b/backend/api/src/ship-profiles.ts @@ -5,7 +5,7 @@ import { log } from 'shared/utils' import { tryCatch } from 'common/util/try-catch' import { insert } from 'shared/supabase/utils' -export const shipLovers: APIHandler<'ship-profiles'> = async (props, auth) => { +export const shipProfiles: APIHandler<'ship-profiles'> = async (props, auth) => { const { targetUserId1, targetUserId2, remove } = props const creatorId = auth.uid diff --git a/backend/shared/src/love/supabase.ts b/backend/shared/src/love/supabase.ts index af7989fe..5a75b1f5 100644 --- a/backend/shared/src/love/supabase.ts +++ b/backend/shared/src/love/supabase.ts @@ -58,7 +58,7 @@ export const getProfiles = async (userIds: string[]) => { ) } -export const getGenderCompatibleLovers = async (lover: LoverRow) => { +export const getGenderCompatibleProfiles = async (lover: LoverRow) => { const pg = createSupabaseDirectClient() const profiles = await pg.map( ` @@ -80,7 +80,7 @@ export const getGenderCompatibleLovers = async (lover: LoverRow) => { return profiles.filter((l: Lover) => areGenderCompatible(lover, l)) } -export const getCompatibleLovers = async ( +export const getCompatibleProfiles = async ( lover: LoverRow, radiusKm: number | undefined ) => { diff --git a/common/src/api/schema.ts b/common/src/api/schema.ts index baaff7f4..a35fc106 100644 --- a/common/src/api/schema.ts +++ b/common/src/api/schema.ts @@ -1,7 +1,7 @@ import { contentSchema, combinedLoveUsersSchema, - baseLoversSchema, + baseProfilesSchema, arraybeSchema, } from 'common/api/zod-types' import { PrivateChatMessage } from 'common/chat-message' @@ -92,7 +92,7 @@ export const API = (_apiTypeCheck = { method: 'POST', authed: true, returns: {} as Row<'profiles'>, - props: baseLoversSchema, + props: baseProfilesSchema, }, report: { method: 'POST', @@ -218,7 +218,7 @@ export const API = (_apiTypeCheck = { props: z.object({ userId: z.string() }), returns: {} as { lover: Lover - compatibleLovers: Lover[] + compatibleProfiles: Lover[] loverCompatibilityScores: { [userId: string]: CompatibilityScore } diff --git a/common/src/api/zod-types.ts b/common/src/api/zod-types.ts index 6153e75c..2556a25e 100644 --- a/common/src/api/zod-types.ts +++ b/common/src/api/zod-types.ts @@ -42,7 +42,7 @@ const genderType = z.string() // ]) const genderTypes = z.array(genderType) -export const baseLoversSchema = z.object({ +export const baseProfilesSchema = z.object({ // Required fields age: z.number().min(18).max(100).optional(), gender: genderType, @@ -74,7 +74,7 @@ export const baseLoversSchema = z.object({ referred_by_username: z.string().optional(), }) -const optionalLoversSchema = z.object({ +const optionalProfilesSchema = z.object({ political_beliefs: z.array(z.string()).optional(), religious_belief_strength: z.number().optional(), religious_beliefs: z.string().optional(), @@ -100,4 +100,4 @@ const optionalLoversSchema = z.object({ }) export const combinedLoveUsersSchema = - baseLoversSchema.merge(optionalLoversSchema) + baseProfilesSchema.merge(optionalProfilesSchema) diff --git a/common/src/filters.ts b/common/src/filters.ts index 17421e2d..e0d6eb8d 100644 --- a/common/src/filters.ts +++ b/common/src/filters.ts @@ -17,7 +17,7 @@ export type FilterFields = { | 'pref_age_min' | 'pref_age_max' > -export const orderLovers = ( +export const orderProfiles = ( profiles: Lover[], starredUserIds: string[] | undefined ) => { diff --git a/web/components/browse-matches-button.tsx b/web/components/browse-matches-button.tsx index 7b859be0..aad17f91 100644 --- a/web/components/browse-matches-button.tsx +++ b/web/components/browse-matches-button.tsx @@ -20,17 +20,17 @@ import { Input } from 'web/components/widgets/input' export const BrowseMatchesButton = (props: { lover: Lover - potentialLovers: Lover[] + potentialProfiles: Lover[] compatibilityScores: Record className?: string }) => { - const { lover, potentialLovers, compatibilityScores, className } = props + const { lover, potentialProfiles, compatibilityScores, className } = props const currentUser = useUser() const isCurrentUser = currentUser?.id === lover.user_id const [dialogOpen, setDialogOpen] = useState(false) - const key = `comment ${potentialLovers.map((l) => l.id).join(',')}` + const key = `comment ${potentialProfiles.map((l) => l.id).join(',')}` const editor = useTextEditor({ key, size: 'sm', @@ -82,7 +82,7 @@ export const BrowseMatchesButton = (props: { {dialogOpen && ( isSubmitting: boolean setOpen: (open: boolean) => void @@ -105,7 +105,7 @@ const BrowseMatchesDialog = (props: { }) => { const { lover, - potentialLovers, + potentialProfiles, compatibilityScores, isSubmitting, setOpen, @@ -119,12 +119,12 @@ const BrowseMatchesDialog = (props: { const currentUser = useUser() const isCurrentUser = currentUser?.id === lover.user_id - const filteredLovers = potentialLovers.filter((lover) => + const filteredProfiles = potentialProfiles.filter((lover) => lover.user.name.toLowerCase().includes(query.toLowerCase()) ) const [potentialIndex, setPotentialIndex] = useState(0) - const index = Math.min(potentialIndex, filteredLovers.length - 1) - const potentialLover = filteredLovers[index] + const index = Math.min(potentialIndex, filteredProfiles.length - 1) + const potentialLover = filteredProfiles[index] const compatibility = potentialLover ? compatibilityScores[potentialLover.user_id] @@ -151,7 +151,7 @@ const BrowseMatchesDialog = (props: { }} /> - {filteredLovers.length === 0 ? ( + {filteredProfiles.length === 0 ? (
No remaining compatible matches.
@@ -163,7 +163,7 @@ const BrowseMatchesDialog = (props: { className="self-start" page={index} setPage={setPotentialIndex} - totalItems={filteredLovers.length} + totalItems={filteredProfiles.length} pageSize={1} /> )} diff --git a/web/components/profiles/profiles-home.tsx b/web/components/profiles/profiles-home.tsx index 709c133c..a25dcacd 100644 --- a/web/components/profiles/profiles-home.tsx +++ b/web/components/profiles/profiles-home.tsx @@ -2,7 +2,7 @@ import {Lover} from 'common/love/lover' import {removeNullOrUndefinedProps} from 'common/util/object' import {Search} from 'web/components/filters/search' import {useLover} from 'web/hooks/use-lover' -import {useCompatibleLovers} from 'web/hooks/use-profiles' +import {useCompatibleProfiles} from 'web/hooks/use-profiles' import {getStars} from 'web/lib/supabase/stars' import Router from 'next/router' import {useCallback, useEffect, useRef, useState} from 'react' @@ -15,7 +15,7 @@ import {usePersistentInMemoryState} from 'web/hooks/use-persistent-in-memory-sta import {useUser} from 'web/hooks/use-user' import {api} from 'web/lib/api' import {useBookmarkedSearches} from "web/hooks/use-bookmarked-searches"; -import {orderLovers} from "common/filters"; +import {orderProfiles} from "common/filters"; import {useFilters} from "web/components/filters/use-filters"; export function ProfilesHome() { @@ -32,7 +32,7 @@ export function ProfilesHome() { locationFilterProps, } = useFilters(you ?? undefined); - const [profiles, setLovers] = usePersistentInMemoryState(undefined, 'profile-profiles'); + const [profiles, setProfiles] = usePersistentInMemoryState(undefined, 'profile-profiles'); const {bookmarkedSearches, refreshBookmarkedSearches} = useBookmarkedSearches(user?.id) const [isLoadingMore, setIsLoadingMore] = useState(false); const [isReloading, setIsReloading] = useState(false); @@ -60,7 +60,7 @@ export function ProfilesHome() { ...filters }) as any) .then(({profiles}) => { - if (current === id.current) setLovers(profiles); + if (current === id.current) setProfiles(profiles); }) .finally(() => { if (current === id.current) setIsReloading(false); @@ -68,8 +68,8 @@ export function ProfilesHome() { }, [filters]); const {data: starredUserIds, refresh: refreshStars} = useGetter('star', user?.id, getStars); - const compatibleLovers = useCompatibleLovers(user?.id); - const displayLovers = profiles && orderLovers(profiles, starredUserIds); + const compatibleProfiles = useCompatibleProfiles(user?.id); + const displayProfiles = profiles && orderProfiles(profiles, starredUserIds); const loadMore = useCallback(async () => { if (!profiles || isLoadingMore) return false; @@ -83,7 +83,7 @@ export function ProfilesHome() { ...filters }) as any); if (result.profiles.length === 0) return false; - setLovers((prev) => (prev ? [...prev, ...result.profiles] : result.profiles)); + setProfiles((prev) => (prev ? [...prev, ...result.profiles] : result.profiles)); return true; } catch (err) { console.error('Failed to load more profiles', err); @@ -91,7 +91,7 @@ export function ProfilesHome() { } finally { setIsLoadingMore(false); } - }, [profiles, filters, isLoadingMore, setLovers]); + }, [profiles, filters, isLoadingMore, setProfiles]); return ( <> @@ -109,15 +109,15 @@ export function ProfilesHome() { bookmarkedSearches={bookmarkedSearches} refreshBookmarkedSearches={refreshBookmarkedSearches} /> - {displayLovers === undefined || compatibleLovers === undefined ? ( + {displayProfiles === undefined || compatibleProfiles === undefined ? ( ) : ( diff --git a/web/hooks/use-profiles.ts b/web/hooks/use-profiles.ts index 66e02df4..b060fdfd 100644 --- a/web/hooks/use-profiles.ts +++ b/web/hooks/use-profiles.ts @@ -6,7 +6,7 @@ import { APIResponse } from 'common/api/schema' import { useLoverByUserId } from './use-lover' import { getProfilesCompatibilityFactor } from 'common/love/compatibility-score' -export const useCompatibleLovers = ( +export const useCompatibleProfiles = ( userId: string | null | undefined, options?: { sortWithModifiers?: boolean } ) => { @@ -31,7 +31,7 @@ export const useCompatibleLovers = ( }, [userId]) if (data && lover && options?.sortWithModifiers) { - data.compatibleLovers = sortBy(data.compatibleLovers, (l) => { + data.compatibleProfiles = sortBy(data.compatibleProfiles, (l) => { const modifier = !lover ? 1 : getProfilesCompatibilityFactor(lover, l) return -1 * modifier * data.loverCompatibilityScores[l.user.id].score })