Files
otunes/apps/mobile/hooks/use-profile-image-url.ts
T

14 lines
448 B
TypeScript

import { useServerConfig } from "@/contexts/server-config"
/**
* Resolves `currentUser.image` to a loadable URI. Stored avatars come back as
* paths on the oTunes web server; legacy ones are data URLs.
*/
export function useProfileImageUrl(image: string | undefined) {
const { config } = useServerConfig()
if (!image?.startsWith("/")) {
return image
}
return config ? `${config.serverUrl.replace(/\/+$/, "")}${image}` : undefined
}