Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
941 B · 28 lines
TypeScript
1234567891011121314151617181920212223242526272829import type { LivestreamStore } from "@streamplace/core";import { useMemo } from "react";import { useStore } from "zustand";import { useShallow } from "zustand/react/shallow";import { resolveStreamAvatar } from "./resolve-stream-avatar";import useAvatars from "./use-avatars";
export function useStreamAvatar(store: LivestreamStore): string | undefined { const identity = useStore( store, useShallow((state) => ({ did: state.profile?.did ?? state.livestream?.author.did, profileAvatar: state.profile?.avatar, authorAvatar: state.livestream?.author.avatar, })), ); const dids = useMemo( () => (identity.did ? [identity.did] : []), [identity.did], ); const profiles = useAvatars(dids);
return resolveStreamAvatar({ detailedAvatar: identity.did ? profiles[identity.did]?.avatar : undefined, profileAvatar: identity.profileAvatar, authorAvatar: identity.authorAvatar, });}