an app to share curated trails sidetrail.app
1

Configure Feed

Select the types of activity you want to include in your feed.

at main 552 B View raw
1"use client"; 2 3import { useLoginModal } from "@/app/LoginModalContext"; 4import { useAuthContext } from "@/app/AuthContext"; 5 6export function useAuthAction() { 7 const { openLoginModal } = useLoginModal(); 8 const { didPromise } = useAuthContext(); 9 10 return <Args extends unknown[], R>(action: (...args: Args) => Promise<R>) => 11 async (...args: Args): Promise<R | undefined> => { 12 const did = await didPromise; 13 if (did) { 14 return action(...args); 15 } else { 16 openLoginModal(); 17 return undefined; 18 } 19 }; 20}