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";
|
||||
|
||||
|
||||
@@ -11,12 +11,12 @@ export function MembersList({
|
||||
currentUserId,
|
||||
onRemoveMember,
|
||||
disableActions,
|
||||
}: {
|
||||
}: Readonly<{
|
||||
members: MemberEntry[];
|
||||
currentUserId?: string;
|
||||
onRemoveMember?: (userId: string) => void;
|
||||
disableActions?: boolean;
|
||||
}) {
|
||||
}>) {
|
||||
if (members.length === 0) return null;
|
||||
|
||||
return (
|
||||
|
||||
@@ -9,9 +9,9 @@ import { buildMemberMap } from "./member-map";
|
||||
|
||||
export default async function RoomDetailPage({
|
||||
params,
|
||||
}: {
|
||||
}: Readonly<{
|
||||
params: Promise<{ id: string }>;
|
||||
}) {
|
||||
}>) {
|
||||
const { id } = await params;
|
||||
const supabase = await createClient();
|
||||
|
||||
@@ -43,9 +43,9 @@ export default async function RoomDetailPage({
|
||||
]);
|
||||
|
||||
return (
|
||||
<div className="flex h-full flex-col">
|
||||
<div className="flex h-[calc(100vh)] flex-col md:h-screen">
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between border-b border-neutral-200 bg-white px-6 py-3">
|
||||
<div className="flex shrink-0 items-center justify-between bg-white px-6 py-3">
|
||||
<div className="flex items-center gap-3">
|
||||
<Link
|
||||
href="/rooms"
|
||||
@@ -77,7 +77,7 @@ export default async function RoomDetailPage({
|
||||
</div>
|
||||
|
||||
{/* Chat */}
|
||||
<div className="flex-1 overflow-hidden">
|
||||
<div className="flex min-h-0 flex-1 flex-col overflow-hidden">
|
||||
<Chat
|
||||
roomId={id}
|
||||
initialMessages={messages}
|
||||
|
||||
@@ -10,11 +10,11 @@ export function RoomSettings({
|
||||
roomId,
|
||||
members,
|
||||
currentUserId,
|
||||
}: {
|
||||
}: Readonly<{
|
||||
roomId: string;
|
||||
members: MemberEntry[];
|
||||
currentUserId: string;
|
||||
}) {
|
||||
}>) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const [deleting, setDeleting] = useState(false);
|
||||
const [removeError, setRemoveError] = useState<string | null>(null);
|
||||
@@ -59,7 +59,7 @@ export function RoomSettings({
|
||||
>
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
d="M2 4.75A.75.75 0 0 1 2.75 4h14.5a.75.75 0 0 1 0 1.5H2.75A.75.75 0 0 1 2 4.75ZM2 10a.75.75 0 0 1 .75-.75h14.5a.75.75 0 0 1 0 1.5H2.75A.75.75 0 0 1 2 10Zm0 5.25a.75.75 0 0 1 .75-.75h14.5a.75.75 0 0 1 0 1.5H2.75a.75.75 0 0 1-.75-.75Z"
|
||||
d="M7.84 1.804A1 1 0 0 1 8.82 1h2.36a1 1 0 0 1 .98.804l.331 1.652a6.993 6.993 0 0 1 1.929 1.115l1.598-.54a1 1 0 0 1 1.186.447l1.18 2.044a1 1 0 0 1-.205 1.251l-1.267 1.113a7.047 7.047 0 0 1 0 2.228l1.267 1.113a1 1 0 0 1 .206 1.25l-1.18 2.045a1 1 0 0 1-1.87.447l-1.598-.54a6.993 6.993 0 0 1-1.929 1.115l-.33 1.652a1 1 0 0 1-.98.804H8.82a1 1 0 0 1-.98-.804l-.331-1.652a6.993 6.993 0 0 1-1.929-1.115l-1.598.54a1 1 0 0 1-1.186-.447l-1.18-2.044a1 1 0 0 1 .205-1.251l1.267-1.114a7.05 7.05 0 0 1 0-2.227L1.821 7.773a1 1 0 0 1-.206-1.25l1.18-2.045a1 1 0 0 1 1.187-.447l1.598.54A6.993 6.993 0 0 1 7.51 3.456l.33-1.652ZM10 13a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"
|
||||
clipRule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
|
||||
Reference in new issue
Block a user