Reimplemented rooms with live update
This commit is contained in:
1 parent
347f4b0999
commit
94c544b161
7 files changed
+25
-23
No files matched your search
@@ -28,12 +28,12 @@ export function Chat({
|
||||
initialMessages,
|
||||
currentUserId,
|
||||
memberMap,
|
||||
}: {
|
||||
}: Readonly<{
|
||||
roomId: string;
|
||||
initialMessages: Message[];
|
||||
currentUserId: string;
|
||||
memberMap: Map<string, MemberInfo>;
|
||||
}) {
|
||||
}>) {
|
||||
const boundAction = sendMessageAction.bind(null, roomId);
|
||||
const [state, action, pending] = useActionState(boundAction, initialState);
|
||||
const formRef = useRef<HTMLFormElement>(null);
|
||||
@@ -197,16 +197,16 @@ export function Chat({
|
||||
.subscribe();
|
||||
|
||||
return () => {
|
||||
void supabase.removeChannel(channel);
|
||||
supabase.removeChannel(channel);
|
||||
};
|
||||
}, [roomId, memberMap, currentUserId]);
|
||||
|
||||
const displayMessages = [...messages].reverse();
|
||||
|
||||
return (
|
||||
<div className=" rounded-xl border border-neutral-200 bg-white shadow-sm">
|
||||
<div className="flex min-h-0 flex-1 flex-col border-t-1 border-neutral-200 bg-white shadow-sm">
|
||||
{/* Messages area */}
|
||||
<div className="h-[calc(100vh-20rem)] overflow-y-auto p-4">
|
||||
<div className="flex-1 overflow-y-auto p-4">
|
||||
{displayMessages.length === 0 ? (
|
||||
<div className="flex h-full items-center justify-center">
|
||||
<p className="text-sm text-neutral-400">
|
||||
@@ -296,11 +296,11 @@ function Avatar({
|
||||
name,
|
||||
avatarUrl,
|
||||
size = "md",
|
||||
}: {
|
||||
}: Readonly<{
|
||||
name: string;
|
||||
avatarUrl: string | null;
|
||||
size?: "sm" | "md";
|
||||
}) {
|
||||
}>) {
|
||||
const sizeClass = size === "sm" ? "size-5" : "size-8";
|
||||
const textSize = size === "sm" ? "text-[10px]" : "text-xs";
|
||||
|
||||
|
||||
Reference in new issue
Block a user