fix(cordn): share public invite URL from the native app

This commit is contained in:
SkateSpots 2026-10-27 16:38:33 +07:00
parent ac5ac85004
commit 7881bbc50f

View file

@ -38,6 +38,7 @@ import { useCurrentUser } from '@/hooks/useCurrentUser';
import { useUploadFile } from '@/hooks/useUploadFile'; import { useUploadFile } from '@/hooks/useUploadFile';
import { useCordnNative } from '@/hooks/useCordnNative'; import { useCordnNative } from '@/hooks/useCordnNative';
import { shortNpub } from '@/lib/coordinator'; import { shortNpub } from '@/lib/coordinator';
import { isNativePlatform } from '@/lib/platform';
import { formatDistanceToNow } from '@/lib/dateFnsI18n'; import { formatDistanceToNow } from '@/lib/dateFnsI18n';
import { cn } from '@/lib/utils'; import { cn } from '@/lib/utils';
import type { SkateCrew } from '@/lib/types'; import type { SkateCrew } from '@/lib/types';
@ -83,10 +84,13 @@ export function CordnNativePanel({ crew, canManage, isMember }: CordnNativePanel
const loadedRequestsRef = useRef(false); const loadedRequestsRef = useRef(false);
const { mutateAsync: uploadFile, isPending: uploading } = useUploadFile(); const { mutateAsync: uploadFile, isPending: uploading } = useUploadFile();
const inviteUrl = useMemo( const inviteUrl = useMemo(() => {
() => `${window.location.origin}/#/crew/${crew.pubkey}/${crew.identifier}?tab=mls`, // In the Android/iOS shell the page origin is `https://localhost`, which is
[crew.pubkey, crew.identifier], // useless in a QR code. Share the public site there; keep the live origin on
); // the web (including previews).
const origin = isNativePlatform() ? 'https://skate-spots.org' : window.location.origin;
return `${origin}/#/crew/${crew.pubkey}/${crew.identifier}?tab=mls`;
}, [crew.pubkey, crew.identifier]);
useEffect(() => { useEffect(() => {
scrollRef.current?.scrollTo({ top: scrollRef.current.scrollHeight }); scrollRef.current?.scrollTo({ top: scrollRef.current.scrollHeight });