Merge pull request 'feat: streamer icon' (#23) from verbiricha/stream:feat/streamer-icon into main

Reviewed-on: Kieran/stream#23
This commit is contained in:
Kieran 2023-07-05 20:09:06 +00:00
commit a8c47a9863
2 changed files with 24 additions and 5 deletions

View File

@ -101,7 +101,15 @@ export function ChatMessage({
ref={ref} ref={ref}
onClick={() => setShowZapDialog(true)} onClick={() => setShowZapDialog(true)}
> >
<Profile pubkey={ev.pubkey} profile={profile} /> <Profile
icon={
ev.pubkey === streamer && (
<Icon name="signal" size={16} />
)
}
pubkey={ev.pubkey}
profile={profile}
/>
<Text content={ev.content} tags={ev.tags} /> <Text content={ev.content} tags={ev.tags} />
{(hasReactions || hasZaps) && ( {(hasReactions || hasZaps) && (
<div className="message-reactions"> <div className="message-reactions">

View File

@ -1,4 +1,5 @@
import "./profile.css"; import "./profile.css";
import type { ReactNode } from "react";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { useUserProfile } from "@snort/system-react"; import { useUserProfile } from "@snort/system-react";
import { UserMetadata } from "@snort/system"; import { UserMetadata } from "@snort/system";
@ -28,17 +29,20 @@ export function getName(pk: string, user?: UserMetadata) {
export function Profile({ export function Profile({
pubkey, pubkey,
icon,
avatarClassname, avatarClassname,
options, options,
profile, profile,
}: { }: {
pubkey: string; pubkey: string;
icon?: ReactNode;
avatarClassname?: string; avatarClassname?: string;
options?: ProfileOptions; options?: ProfileOptions;
profile?: UserMetadata profile?: UserMetadata;
}) { }) {
const { inView, ref } = useInView(); const { inView, ref } = useInView();
const pLoaded = useUserProfile(System, inView && !profile ? pubkey : undefined) || profile; const pLoaded =
useUserProfile(System, inView && !profile ? pubkey : undefined) || profile;
const showAvatar = options?.showAvatar ?? true; const showAvatar = options?.showAvatar ?? true;
const showName = options?.showName ?? true; const showName = options?.showName ?? true;
@ -54,6 +58,7 @@ export function Profile({
src={pLoaded?.picture ?? ""} src={pLoaded?.picture ?? ""}
/> />
))} ))}
{icon}
{showName && ( {showName && (
<span> <span>
{options?.overrideName ?? pubkey === "anon" {options?.overrideName ?? pubkey === "anon"
@ -65,9 +70,15 @@ export function Profile({
); );
return pubkey === "anon" ? ( return pubkey === "anon" ? (
<div className="profile" ref={ref}>{content}</div> <div className="profile" ref={ref}>
{content}
</div>
) : ( ) : (
<Link to={`/p/${hexToBech32("npub", pubkey)}`} className="profile" ref={ref}> <Link
to={`/p/${hexToBech32("npub", pubkey)}`}
className="profile"
ref={ref}
>
{content} {content}
</Link> </Link>
); );