fix: remove unused imports and variables in thread-pane
This commit is contained in:
parent
ccc344debd
commit
41bd76c45b
@ -2,11 +2,8 @@ import { useCallback, useEffect, useRef, useState } from "react";
|
|||||||
import {
|
import {
|
||||||
Loader2,
|
Loader2,
|
||||||
MessageSquarePlus,
|
MessageSquarePlus,
|
||||||
X,
|
|
||||||
ArrowLeft,
|
ArrowLeft,
|
||||||
Send,
|
Send,
|
||||||
Flame,
|
|
||||||
CornerDownRight,
|
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { api } from "@/client";
|
import { api } from "@/client";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
@ -26,27 +23,6 @@ function formatTime(iso: string) {
|
|||||||
return d.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
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) {
|
export default function ThreadPane({ thread, roomId, onClose }: Props) {
|
||||||
const [messages, setMessages] = useState<MessageNewService[]>([]);
|
const [messages, setMessages] = useState<MessageNewService[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
@ -55,9 +31,6 @@ export default function ThreadPane({ thread, roomId, onClose }: Props) {
|
|||||||
const bottomRef = useRef<HTMLDivElement>(null);
|
const bottomRef = useRef<HTMLDivElement>(null);
|
||||||
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
||||||
|
|
||||||
const creatorName =
|
|
||||||
thread.created_by.display_name || thread.created_by.username || "User";
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let cancelled = false;
|
let cancelled = false;
|
||||||
api
|
api
|
||||||
@ -120,7 +93,6 @@ export default function ThreadPane({ thread, roomId, onClose }: Props) {
|
|||||||
messages: { msg: MessageNewService; showHeader: boolean }[];
|
messages: { msg: MessageNewService; showHeader: boolean }[];
|
||||||
}[] = [];
|
}[] = [];
|
||||||
|
|
||||||
let lastDate: string | undefined;
|
|
||||||
for (let i = 0; i < messages.length; i++) {
|
for (let i = 0; i < messages.length; i++) {
|
||||||
const msg = messages[i];
|
const msg = messages[i];
|
||||||
const prev = i > 0 ? messages[i - 1] : undefined;
|
const prev = i > 0 ? messages[i - 1] : undefined;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user