diff --git a/lib/src/Components/Map/Subcomponents/ItemPopupComponents/HeaderView/hooks.ts b/lib/src/Components/Map/Subcomponents/ItemPopupComponents/HeaderView/hooks.ts index 9fc6d446..a5818b86 100644 --- a/lib/src/Components/Map/Subcomponents/ItemPopupComponents/HeaderView/hooks.ts +++ b/lib/src/Components/Map/Subcomponents/ItemPopupComponents/HeaderView/hooks.ts @@ -34,10 +34,10 @@ export const useNavigationUrl = (coordinates?: [number, number]) => { export const useShareLogic = (item?: Item) => { const shareUrl = window.location.href const shareTitle = item?.name ?? 'Utopia Map Item' - const inviteLink = - item?.secrets && item.secrets.length > 0 - ? `${window.location.origin}/invite/${item.secrets[0].secret}` - : shareUrl + const firstSecret = item?.secrets?.[0] + // Support both string secrets and object secrets with { secret: string } + const secretValue = typeof firstSecret === 'string' ? firstSecret : firstSecret?.secret + const inviteLink = secretValue ? `${window.location.origin}/invite/${secretValue}` : shareUrl const copyLink = () => { navigator.clipboard diff --git a/lib/src/Components/Map/hooks/useMyProfile.ts b/lib/src/Components/Map/hooks/useMyProfile.ts index 74abb055..c35c00b0 100644 --- a/lib/src/Components/Map/hooks/useMyProfile.ts +++ b/lib/src/Components/Map/hooks/useMyProfile.ts @@ -32,6 +32,7 @@ export const useMyProfile = () => { const retryDelay = 500 // ms for (let i = 0; i < maxRetries; i++) { + // eslint-disable-next-line promise/avoid-new await new Promise((resolve) => setTimeout(resolve, retryDelay)) const reloaded = await layer.api?.getItem?.(itemId) if (reloaded?.secrets && reloaded.secrets.length > 0) { @@ -45,19 +46,16 @@ export const useMyProfile = () => { } // Automatically reload profile if secrets are missing (e.g., after signup) + const hasSecrets = myProfile?.secrets && myProfile.secrets.length > 0 useEffect(() => { - if ( - myProfile?.layer?.api?.getItem && - (!myProfile.secrets || myProfile.secrets.length === 0) && - !isReloadingSecretRef.current - ) { + if (myProfile?.layer?.api?.getItem && !hasSecrets && !isReloadingSecretRef.current) { isReloadingSecretRef.current = true void reloadItemWithSecret(myProfile.id, myProfile.layer, myProfile).finally(() => { isReloadingSecretRef.current = false }) } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [myProfile?.id, myProfile?.secrets?.length]) + }, [myProfile?.id, hasSecrets]) const createEmptyProfile = async () => { if (!user) return @@ -76,9 +74,9 @@ export const useMyProfile = () => { const newItem = { ...serverResponse, - user_created: user, + user_created: user, // eslint-disable-line camelcase layer: userLayer, - public_edit: false, + public_edit: false, // eslint-disable-line camelcase } // Add item immediately (without secret) diff --git a/lib/src/Components/Onboarding/InvitePage.tsx b/lib/src/Components/Onboarding/InvitePage.tsx index 037ea0b1..badda672 100644 --- a/lib/src/Components/Onboarding/InvitePage.tsx +++ b/lib/src/Components/Onboarding/InvitePage.tsx @@ -76,6 +76,7 @@ export function InvitePage({ inviteApi, itemsApi }: Props) { { type: 'is_following', direction: 'outgoing', + // eslint-disable-next-line camelcase related_items_id: invitingProfile.id, }, ], diff --git a/lib/src/Components/Profile/Subcomponents/InviteLinkView.tsx b/lib/src/Components/Profile/Subcomponents/InviteLinkView.tsx index 34bf615b..ca4214ec 100644 --- a/lib/src/Components/Profile/Subcomponents/InviteLinkView.tsx +++ b/lib/src/Components/Profile/Subcomponents/InviteLinkView.tsx @@ -8,7 +8,12 @@ export const InviteLinkView = ({ item }: { item: Item }) => { // Only show if user has permission to view secrets. if (!item.secrets || item.secrets.length === 0) return - const link = `${window.location.origin}/invite/${item.secrets[0].secret}` + const firstSecret = item.secrets[0] + // Support both string secrets and object secrets with { secret: string } + const secretValue = typeof firstSecret === 'string' ? firstSecret : firstSecret.secret + if (!secretValue) return + + const link = `${window.location.origin}/invite/${secretValue}` const copyToClipboard = () => { void navigator.clipboard diff --git a/lib/src/Components/Profile/Subcomponents/RelationsView.tsx b/lib/src/Components/Profile/Subcomponents/RelationsView.tsx index c495d013..d67da388 100644 --- a/lib/src/Components/Profile/Subcomponents/RelationsView.tsx +++ b/lib/src/Components/Profile/Subcomponents/RelationsView.tsx @@ -1,9 +1,7 @@ -import { MapPinIcon } from '@heroicons/react/24/solid' import { Link } from 'react-router-dom' import { useAppState } from '#components/AppShell/hooks/useAppState' import { useItems } from '#components/Map/hooks/useItems' -import { useReverseGeocode } from '#components/Map/hooks/useReverseGeocode' import type { Item } from '#types/Item' @@ -19,12 +17,6 @@ function RelationCard({ item }: { item: Item }) { const appState = useAppState() const avatar = item.image ? appState.assetsApi.url + item.image : null - const { address } = useReverseGeocode( - item.position?.coordinates as [number, number] | undefined, - true, - 'municipality', - ) - return (