mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-17 18:35:19 +02:00
feat(shared): extract formatThreadTimestamp helper for chats sidebars (fixes #1376)
- Add formatThreadTimestamp() to surfsense_web/lib/format-date.ts - Use shared helper in AllPrivateChatsSidebar and AllSharedChatsSidebar - Remove unused date-fns format import from both sidebar files - Centralises timestamp formatting policy for future i18n/relative-time changes
This commit is contained in:
parent
83ee58016e
commit
10212f3d5a
3 changed files with 12 additions and 4 deletions
|
|
@ -1,7 +1,7 @@
|
|||
"use client";
|
||||
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { format } from "date-fns";
|
||||
import { formatThreadTimestamp } from "@/lib/format-date";
|
||||
import { useSetAtom } from "jotai";
|
||||
import {
|
||||
ArchiveIcon,
|
||||
|
|
@ -390,7 +390,7 @@ export function AllPrivateChatsSidebarContent({
|
|||
<TooltipContent side="bottom" align="start">
|
||||
<p>
|
||||
{t("updated") || "Updated"}:{" "}
|
||||
{format(new Date(thread.updatedAt), "MMM d, yyyy 'at' h:mm a")}
|
||||
{formatThreadTimestamp(thread.updatedAt)}
|
||||
</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
"use client";
|
||||
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { format } from "date-fns";
|
||||
import { formatThreadTimestamp } from "@/lib/format-date";
|
||||
import { useSetAtom } from "jotai";
|
||||
import {
|
||||
ArchiveIcon,
|
||||
|
|
@ -389,7 +389,7 @@ export function AllSharedChatsSidebarContent({
|
|||
<TooltipContent side="bottom" align="start">
|
||||
<p>
|
||||
{t("updated") || "Updated"}:{" "}
|
||||
{format(new Date(thread.updatedAt), "MMM d, yyyy 'at' h:mm a")}
|
||||
{formatThreadTimestamp(thread.updatedAt)}
|
||||
</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
|
|
|
|||
|
|
@ -22,3 +22,11 @@ export function formatRelativeDate(dateString: string): string {
|
|||
if (daysAgo < 7) return `${daysAgo}d ago`;
|
||||
return format(date, "MMM d, yyyy");
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a thread's last-updated timestamp for the chats sidebars.
|
||||
* Example: "Mar 23, 2026 at 4:30 PM"
|
||||
*/
|
||||
export function formatThreadTimestamp(dateString: string): string {
|
||||
return format(new Date(dateString), "MMM d, yyyy 'at' h:mm a");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue