fix: remove unused imports and variables in thread-pane

This commit is contained in:
zhenyi 2026-05-30 15:00:01 +08:00
parent ccc344debd
commit 41bd76c45b

View File

@ -2,11 +2,8 @@ import { useCallback, useEffect, useRef, useState } from "react";
import {
Loader2,
MessageSquarePlus,
X,
ArrowLeft,
Send,
Flame,
CornerDownRight,
} from "lucide-react";
import { api } from "@/client";
import { Button } from "@/components/ui/button";
@ -26,27 +23,6 @@ function formatTime(iso: string) {
return d.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
}
function formatDate(iso: string) {
const d = new Date(iso);
const now = new Date();
if (d.toDateString() === now.toDateString()) return "Today";
const yesterday = new Date(now);
yesterday.setDate(yesterday.getDate() - 1);
if (d.toDateString() === yesterday.toDateString()) return "Yesterday";
return d.toLocaleDateString([], {
month: "long",
day: "numeric",
year: d.getFullYear() !== now.getFullYear() ? "numeric" : undefined,
});
}
function shouldShowDate(current: string, prev?: string): boolean {
if (!prev) return true;
const cur = new Date(current);
const prv = new Date(prev);
return cur.toDateString() !== prv.toDateString();
}
export default function ThreadPane({ thread, roomId, onClose }: Props) {
const [messages, setMessages] = useState<MessageNewService[]>([]);
const [loading, setLoading] = useState(true);
@ -55,9 +31,6 @@ export default function ThreadPane({ thread, roomId, onClose }: Props) {
const bottomRef = useRef<HTMLDivElement>(null);
const textareaRef = useRef<HTMLTextAreaElement>(null);
const creatorName =
thread.created_by.display_name || thread.created_by.username || "User";
useEffect(() => {
let cancelled = false;
api
@ -120,7 +93,6 @@ export default function ThreadPane({ thread, roomId, onClose }: Props) {
messages: { msg: MessageNewService; showHeader: boolean }[];
}[] = [];
let lastDate: string | undefined;
for (let i = 0; i < messages.length; i++) {
const msg = messages[i];
const prev = i > 0 ? messages[i - 1] : undefined;