jitsi-roomsv2/frontend/src/hooks/useAllChat.tsx
open-schnick 1aa7914289
All checks were successful
continuous-integration/drone/push Build is passing
add prettier and reformat project
2023-04-10 23:36:24 +02:00

22 lines
551 B
TypeScript

import { atom, useAtom } from 'jotai'
import { atomWithReducer, useReducerAtom } from 'jotai/utils'
import { User } from '../background/types/roomData'
interface ChatMessage {
content: string
sender: User
uuid: string
timestamp: number
}
export const allChatMessagesAtom = atomWithReducer([], (list: ChatMessage[], item: ChatMessage) =>
list.concat(item)
)
const useAllChat = () => {
const [chatMessages, addChatMessage] = useAtom(allChatMessagesAtom)
return { chatMesages: chatMessages, addChatMessage }
}
export default useAllChat