diff --git a/surfsense_web/atoms/chat-comments/comments-mutation.atoms.ts b/surfsense_web/atoms/chat-comments/comments-mutation.atoms.ts index a0cabe1a9..73fdbf330 100644 --- a/surfsense_web/atoms/chat-comments/comments-mutation.atoms.ts +++ b/surfsense_web/atoms/chat-comments/comments-mutation.atoms.ts @@ -107,4 +107,3 @@ export const markAllMentionsReadMutationAtom = atomWithMutation(() => ({ toast.error("Failed to mark mentions as read"); }, })); - diff --git a/surfsense_web/atoms/chat-comments/comments-query.atoms.ts b/surfsense_web/atoms/chat-comments/comments-query.atoms.ts index 02b094147..c8c3d2fb6 100644 --- a/surfsense_web/atoms/chat-comments/comments-query.atoms.ts +++ b/surfsense_web/atoms/chat-comments/comments-query.atoms.ts @@ -29,4 +29,3 @@ export const unreadMentionsAtom = atomWithQuery((get) => { }, }; }); - diff --git a/surfsense_web/components/chat-comments/comment-composer/comment-composer.tsx b/surfsense_web/components/chat-comments/comment-composer/comment-composer.tsx index 58e046117..559fd0fa9 100644 --- a/surfsense_web/components/chat-comments/comment-composer/comment-composer.tsx +++ b/surfsense_web/components/chat-comments/comment-composer/comment-composer.tsx @@ -10,18 +10,16 @@ import { MemberMentionPicker } from "../member-mention-picker/member-mention-pic import type { MemberOption } from "../member-mention-picker/types"; import type { CommentComposerProps, InsertedMention, MentionState } from "./types"; -function convertDisplayToData( - displayContent: string, - mentions: InsertedMention[] -): string { +function convertDisplayToData(displayContent: string, mentions: InsertedMention[]): string { let result = displayContent; - const sortedMentions = [...mentions].sort( - (a, b) => b.displayName.length - a.displayName.length - ); + const sortedMentions = [...mentions].sort((a, b) => b.displayName.length - a.displayName.length); for (const mention of sortedMentions) { - const displayPattern = new RegExp(`@${escapeRegExp(mention.displayName)}(?=\\s|$|[.,!?;:])`, 'g'); + const displayPattern = new RegExp( + `@${escapeRegExp(mention.displayName)}(?=\\s|$|[.,!?;:])`, + "g" + ); const dataFormat = `@[${mention.id}]`; result = result.replace(displayPattern, dataFormat); } @@ -30,7 +28,7 @@ function convertDisplayToData( } function escapeRegExp(string: string): string { - return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); } function findMentionTrigger( @@ -39,9 +37,9 @@ function findMentionTrigger( insertedMentions: InsertedMention[] ): { isActive: boolean; query: string; startIndex: number } { const textBeforeCursor = text.slice(0, cursorPos); - + const mentionMatch = textBeforeCursor.match(/(?:^|[\s])@([^\s]*)$/); - + if (!mentionMatch) { return { isActive: false, query: "", startIndex: 0 }; } @@ -58,10 +56,10 @@ function findMentionTrigger( } const textFromAt = text.slice(atIndex); - + for (const mention of insertedMentions) { const mentionPattern = `@${mention.displayName}`; - + if (textFromAt.startsWith(mentionPattern)) { const charAfterMention = text[atIndex + mentionPattern.length]; if (!charAfterMention || /[\s.,!?;:]/.test(charAfterMention)) { @@ -146,7 +144,7 @@ export function CommentComposer({ setDisplayContent(value); const triggerResult = findMentionTrigger(value, cursorPos, insertedMentions); - + if (triggerResult.isActive) { setMentionState(triggerResult); setHighlightedIndex(0); @@ -169,21 +167,15 @@ export function CommentComposer({ case "Tab": if (!e.shiftKey) { e.preventDefault(); - setHighlightedIndex((prev) => - prev < filteredMembers.length - 1 ? prev + 1 : 0 - ); + setHighlightedIndex((prev) => (prev < filteredMembers.length - 1 ? prev + 1 : 0)); } else if (e.key === "Tab") { e.preventDefault(); - setHighlightedIndex((prev) => - prev > 0 ? prev - 1 : filteredMembers.length - 1 - ); + setHighlightedIndex((prev) => (prev > 0 ? prev - 1 : filteredMembers.length - 1)); } break; case "ArrowUp": e.preventDefault(); - setHighlightedIndex((prev) => - prev > 0 ? prev - 1 : filteredMembers.length - 1 - ); + setHighlightedIndex((prev) => (prev > 0 ? prev - 1 : filteredMembers.length - 1)); break; case "Enter": e.preventDefault(); diff --git a/surfsense_web/components/chat-comments/comment-composer/types.ts b/surfsense_web/components/chat-comments/comment-composer/types.ts index 1a891ddcd..c23a96ab9 100644 --- a/surfsense_web/components/chat-comments/comment-composer/types.ts +++ b/surfsense_web/components/chat-comments/comment-composer/types.ts @@ -21,4 +21,3 @@ export interface InsertedMention { id: string; displayName: string; } - diff --git a/surfsense_web/components/chat-comments/comment-item/comment-actions.tsx b/surfsense_web/components/chat-comments/comment-item/comment-actions.tsx index 5a59c5d83..a886521a7 100644 --- a/surfsense_web/components/chat-comments/comment-item/comment-actions.tsx +++ b/surfsense_web/components/chat-comments/comment-item/comment-actions.tsx @@ -10,12 +10,7 @@ import { } from "@/components/ui/dropdown-menu"; import type { CommentActionsProps } from "./types"; -export function CommentActions({ - canEdit, - canDelete, - onEdit, - onDelete, -}: CommentActionsProps) { +export function CommentActions({ canEdit, canDelete, onEdit, onDelete }: CommentActionsProps) { if (!canEdit && !canDelete) { return null; } @@ -48,4 +43,3 @@ export function CommentActions({ ); } - diff --git a/surfsense_web/components/chat-comments/comment-item/comment-item.tsx b/surfsense_web/components/chat-comments/comment-item/comment-item.tsx index 1d5428268..ea9eb1e12 100644 --- a/surfsense_web/components/chat-comments/comment-item/comment-item.tsx +++ b/surfsense_web/components/chat-comments/comment-item/comment-item.tsx @@ -56,11 +56,13 @@ function formatTimestamp(dateString: string): string { return `${dayName} at ${timeStr}`; } - return date.toLocaleDateString("en-US", { - month: "short", - day: "numeric", - year: date.getFullYear() !== now.getFullYear() ? "numeric" : undefined, - }) + ` at ${timeStr}`; + return ( + date.toLocaleDateString("en-US", { + month: "short", + day: "numeric", + year: date.getFullYear() !== now.getFullYear() ? "numeric" : undefined, + }) + ` at ${timeStr}` + ); } function renderMentions(content: string): React.ReactNode { @@ -75,10 +77,7 @@ function renderMentions(content: string): React.ReactNode { } parts.push( - + {match[0]} ); @@ -100,11 +99,12 @@ export function CommentItem({ onReply, isReply = false, }: CommentItemProps) { - const displayName = comment.author?.displayName || comment.author?.email.split("@")[0] || "Unknown"; + const displayName = + comment.author?.displayName || comment.author?.email.split("@")[0] || "Unknown"; const email = comment.author?.email || ""; return ( -
+
{comment.author?.avatarUrl && ( @@ -152,4 +152,3 @@ export function CommentItem({
); } - diff --git a/surfsense_web/components/chat-comments/comment-item/types.ts b/surfsense_web/components/chat-comments/comment-item/types.ts index 8c5d841bc..75add51bf 100644 --- a/surfsense_web/components/chat-comments/comment-item/types.ts +++ b/surfsense_web/components/chat-comments/comment-item/types.ts @@ -31,4 +31,3 @@ export interface CommentActionsProps { onEdit: () => void; onDelete: () => void; } - diff --git a/surfsense_web/components/chat-comments/comment-thread/types.ts b/surfsense_web/components/chat-comments/comment-thread/types.ts index b9bfc1599..a4561039c 100644 --- a/surfsense_web/components/chat-comments/comment-thread/types.ts +++ b/surfsense_web/components/chat-comments/comment-thread/types.ts @@ -1,5 +1,5 @@ -import type { MemberOption } from "../member-mention-picker/types"; import type { CommentData } from "../comment-item/types"; +import type { MemberOption } from "../member-mention-picker/types"; export interface CommentThreadData { id: number; @@ -25,4 +25,3 @@ export interface CommentThreadProps { onDeleteComment: (commentId: number) => void; isSubmitting?: boolean; } - diff --git a/surfsense_web/components/chat-comments/member-mention-picker/member-mention-item.tsx b/surfsense_web/components/chat-comments/member-mention-picker/member-mention-item.tsx index c2e85b892..339cd3758 100644 --- a/surfsense_web/components/chat-comments/member-mention-picker/member-mention-item.tsx +++ b/surfsense_web/components/chat-comments/member-mention-picker/member-mention-item.tsx @@ -47,4 +47,3 @@ export function MemberMentionItem({ ); } - diff --git a/surfsense_web/components/chat-comments/member-mention-picker/member-mention-picker.tsx b/surfsense_web/components/chat-comments/member-mention-picker/member-mention-picker.tsx index 7cc6073eb..77ba1b697 100644 --- a/surfsense_web/components/chat-comments/member-mention-picker/member-mention-picker.tsx +++ b/surfsense_web/components/chat-comments/member-mention-picker/member-mention-picker.tsx @@ -53,4 +53,3 @@ export function MemberMentionPicker({ ); } - diff --git a/surfsense_web/components/chat-comments/member-mention-picker/types.ts b/surfsense_web/components/chat-comments/member-mention-picker/types.ts index 6a653a196..4f190a3e4 100644 --- a/surfsense_web/components/chat-comments/member-mention-picker/types.ts +++ b/surfsense_web/components/chat-comments/member-mention-picker/types.ts @@ -20,4 +20,3 @@ export interface MemberMentionItemProps { onSelect: (member: MemberOption) => void; onMouseEnter: () => void; } - diff --git a/surfsense_web/hooks/use-comments.ts b/surfsense_web/hooks/use-comments.ts index 046ca4520..4f027d67c 100644 --- a/surfsense_web/hooks/use-comments.ts +++ b/surfsense_web/hooks/use-comments.ts @@ -16,4 +16,3 @@ export function useComments({ messageId, enabled = true }: UseCommentsOptions) { enabled: enabled && !!messageId, }); } - diff --git a/surfsense_web/lib/apis/chat-comments-api.service.ts b/surfsense_web/lib/apis/chat-comments-api.service.ts index 8fa683e1c..2f76d9117 100644 --- a/surfsense_web/lib/apis/chat-comments-api.service.ts +++ b/surfsense_web/lib/apis/chat-comments-api.service.ts @@ -1,24 +1,24 @@ import { type CreateCommentRequest, type CreateReplyRequest, - type DeleteCommentRequest, - type GetCommentsRequest, - type GetMentionsRequest, - type MarkMentionReadRequest, - type UpdateCommentRequest, createCommentRequest, createCommentResponse, createReplyRequest, createReplyResponse, + type DeleteCommentRequest, deleteCommentRequest, deleteCommentResponse, + type GetCommentsRequest, + type GetMentionsRequest, getCommentsRequest, getCommentsResponse, getMentionsRequest, getMentionsResponse, + type MarkMentionReadRequest, markAllMentionsReadResponse, markMentionReadRequest, markMentionReadResponse, + type UpdateCommentRequest, updateCommentRequest, updateCommentResponse, } from "@/contracts/types/chat-comments.types"; @@ -90,11 +90,9 @@ class ChatCommentsApiService { throw new ValidationError(`Invalid request: ${errorMessage}`); } - return baseApiService.put( - `/api/v1/comments/${parsed.data.comment_id}`, - updateCommentResponse, - { body: { content: parsed.data.content } } - ); + return baseApiService.put(`/api/v1/comments/${parsed.data.comment_id}`, updateCommentResponse, { + body: { content: parsed.data.content }, + }); }; /** @@ -165,4 +163,3 @@ class ChatCommentsApiService { } export const chatCommentsApiService = new ChatCommentsApiService(); -