Skip to content

Stream-chat-react: Redirecting to profile from user avatar in channel #2670

Open
@AGSTRANGER

Description

@AGSTRANGER

Hello,
I have implemented live chat using stream-chat-react. When the user clicks on the avatar he's talking with I need to redirect to that user's profile:

Image

I couldn't find a way to do this in the documentation.
Here's the relevant code:

    import { Button } from "@/components/ui/button";
    import { cn } from "@/lib/utils";
    import { Menu } from "lucide-react";
    import {
      Channel,
      ChannelHeader,
      ChannelHeaderProps,
      MessageInput,
      MessageList,
      Window,
    } from "stream-chat-react";
    
    interface ChatChannelProps {
      open: boolean;
      openSidebar: () => void;
    }
    
    export default function ChatChannel({ open, openSidebar }: ChatChannelProps) {
      return (
        <div className={cn("w-full md:block", !open && "hidden")}>
          <Channel>
            <Window>
              <CustomChannelHeader openSidebar={openSidebar} />
              <MessageList />
              <MessageInput />
            </Window>
          </Channel>
        </div>
      );
    }
    
    interface CustomChannelHeaderProps extends ChannelHeaderProps {
      openSidebar: () => void;
    }
    
    function CustomChannelHeader({
      openSidebar,
      ...props
    }: CustomChannelHeaderProps) {
      return (
        <div className="flex items-center gap-3">
          <div className="h-full p-2 md:hidden">
            <Button size="icon" variant="ghost" onClick={openSidebar}>
              <Menu className="size-5" />
            </Button>
          </div>
          <ChannelHeader {...props} />
        </div>
      );
    }


Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions