mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 23:16:21 +00:00
dcbf44aedb
Chat tagging: - Any @user is a visible tag in chat bubbles (the .mention-tag CSS never existed, so highlighting was invisible); self/alias mentions get a gold emphasis. Fixes cross-room tags not being highlighted. Mentions window: - Redesigned: unread count in the header, restyled filter chips + a refresh button, CSS-driven list/date-groups, adaptive height (compact when few, capped + scroll when many), polished empty state. - Rows: framed avatar (friends-list head crop so the face is never clipped), per-row unread dot, type marker, icon action buttons (goto / remove). - Re-requests from the server each time it opens. Autocomplete: - Never suggests the viewer themselves; suggests room users + online friends + aliases. Notifications: - Mention toast removed; mentions flow through the client's standard notification stream via a dedicated mention bubble (avatar + actions) in the default position. EVERY received mention surfaces (independent of the generic info-feed toggle, gated only by mentions_ui.enabled). Refactor (behaviour-preserving): - Centralised @-token classification in api/mentions/mentionTokens. - Moved mentionsFormat -> api/mentions, useMentionActions -> hooks/mentions. - Extracted ChatInputView @-autocomplete into a tested useChatMentions hook + pure helper; removed the dead duplicate useMentionAutocomplete.
40 lines
1.5 KiB
TypeScript
40 lines
1.5 KiB
TypeScript
import { CreateLinkEvent, DeleteMentionComposer, MarkMentionsReadComposer } from '@nitrots/nitro-renderer';
|
|
import { useMemo } from 'react';
|
|
import { IMentionEntry, SendMessageComposer } from '../../api';
|
|
import { markRead, removeMention } from './mentionsStore';
|
|
|
|
export interface MentionActions
|
|
{
|
|
/** Row click: mark the mention as read (no navigation). */
|
|
open: (mention: IMentionEntry) => void;
|
|
/** Explicit "go to room" action: mark read, then jump to the origin room. */
|
|
goto: (mention: IMentionEntry) => void;
|
|
/** Permanently delete the mention server-side (DeleteMentionComposer) and
|
|
* drop it from the local list, so it does not reappear after a relog. */
|
|
remove: (mention: IMentionEntry) => void;
|
|
}
|
|
|
|
const markReadOnServer = (mention: IMentionEntry): void =>
|
|
{
|
|
if(mention.read) return;
|
|
markRead(mention.mentionId);
|
|
SendMessageComposer(new MarkMentionsReadComposer(1, mention.mentionId));
|
|
};
|
|
|
|
// Shared action handlers used by both MentionsView and the chat-history
|
|
// "Menzioni" tab so behaviour can't diverge.
|
|
export const useMentionActions = (): MentionActions => useMemo(() => ({
|
|
open: (mention) => markReadOnServer(mention),
|
|
goto: (mention) =>
|
|
{
|
|
markReadOnServer(mention);
|
|
if(mention.roomId > 0) CreateLinkEvent(`navigator/goto/${ mention.roomId }`);
|
|
},
|
|
remove: (mention) =>
|
|
{
|
|
// Permanent server-side delete, then drop it from the local list.
|
|
SendMessageComposer(new DeleteMentionComposer(mention.mentionId));
|
|
removeMention(mention.mentionId);
|
|
}
|
|
}), []);
|