feat: port the chat store, realtime client and components
- realtime.ts: the page's one Centrifuge client, setRealtimeAuth, onUserEvent for user:{me} events the chat does not handle
- chatEvents, chatFormat, chatText, chatUnread, format, media, tabs ported; copy passed in localized
- useChat over useState: channels with join and leave, DMs, member list, unread and mention counts, read marks, typing, presence, polling fallback
- ChatPanel, ChatHeader, ChatMessage, ChatDmList, ChatMemberPicker, ChatMentionPopup, ChatAvatar, ChatIcon, ChatNotices
- EN and PL strings
This commit is contained in:
File diff suppressed because it is too large
Load Diff
26
app/composables/useChatNotice.ts
Normal file
26
app/composables/useChatNotice.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
// The chat's short notices (a failed reaction, a refused pin, a download
|
||||
// error): one message at a time, gone after a few seconds. ChatNotices
|
||||
// renders it inside ChatPage and the floating panel. The message is an i18n
|
||||
// key under chat. with optional parameters.
|
||||
export interface ChatNotice {
|
||||
key: string
|
||||
params?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export function useChatNotice() {
|
||||
const current = useState<ChatNotice | null>('chat:notice', () => null)
|
||||
const nuxtApp = useNuxtApp() as unknown as { _chatNoticeTimer?: ReturnType<typeof setTimeout> }
|
||||
|
||||
function show(key: string, params?: Record<string, unknown>, ms = 4000) {
|
||||
current.value = { key, params }
|
||||
clearTimeout(nuxtApp._chatNoticeTimer)
|
||||
nuxtApp._chatNoticeTimer = setTimeout(() => (current.value = null), ms)
|
||||
}
|
||||
|
||||
function clear() {
|
||||
clearTimeout(nuxtApp._chatNoticeTimer)
|
||||
current.value = null
|
||||
}
|
||||
|
||||
return { current, show, clear }
|
||||
}
|
||||
Reference in New Issue
Block a user