14 lines
448 B
TypeScript
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
|
|
}
|