From 70f5e6fc7e42035a13d8bffd834950f179ca9485 Mon Sep 17 00:00:00 2001 From: Paul Makles Date: Mon, 12 Jun 2023 09:58:13 +0100 Subject: [PATCH] chore: monkey patch ulid parse error --- src/components/common/messaging/bars/NewMessages.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/common/messaging/bars/NewMessages.tsx b/src/components/common/messaging/bars/NewMessages.tsx index d62eb971..f546b4ba 100644 --- a/src/components/common/messaging/bars/NewMessages.tsx +++ b/src/components/common/messaging/bars/NewMessages.tsx @@ -17,6 +17,7 @@ import { Bar } from "./JumpToBottom"; export default observer( ({ channel, last_id }: { channel: Channel; last_id?: string }) => { const [hidden, setHidden] = useState(false); + const [timeAgo, setTimeAgo] = useState(""); const hide = () => setHidden(true); useEffect(() => setHidden(false), [last_id]); @@ -29,6 +30,14 @@ export default observer( return () => document.removeEventListener("keydown", onKeyDown); }, []); + useEffect(() => { + if (last_id) { + try { + setTimeAgo(dayjs(decodeTime(last_id)).fromNow()); + } catch (err) {} + } + }, [last_id]); + const renderer = getRenderer(channel); const history = useHistory(); if (renderer.state !== "RENDER") return null; @@ -52,7 +61,7 @@ export default observer(