Orion Chat & Discussions
This component is relatively complex due to the mechanisms it entails, including interactions with your BackEnd and real-time events.
However, we will try to explain it in a simple way based on the playground below.
TIP
It can be used with the OrionChatDiscussionList
component if you need to manage multiple conversations.
More information can be found in the OrionChatDiscussionList section.
ChatSimple
Props
ChatService = undefined
number = undefined
boolean = false
boolean = false
Events
Orion.Chat.NewMessage
Slots
OrionChatEntity
OrionChatEntity
boolean
OrionChatEntity
PublicInstance
() => Promise<void>
() => number | undefined
(() => HTMLElement | undefined) | undefined
ChatMultipleDiscussions
Props
ChatService = undefined
Events
No payload
number
Slots
No bindings
No bindings
OrionChatEntity
No bindings
ChatService configuration
You can define the configuration of your instance at the time of its creation or later through the config
property.
// Configuration du user à la création
const chat = useChat({ user });
// Configuration de l'écouteur par la suite
chat.config.onNewMessageAsync = async (message, registerMessage) => {
// ...
};
List of parameters:
Orion.Chat.User
The user of your application. This parameter is required upon creation.
boolean
Display the message status (read/unread)
boolean
Display the icon for creating a new discussion in the OrionChatDiscussionList
component
boolean
Enable searching among discussions in the OrionChatDiscussionList
component
number : 500
The delay before triggering the search within discussions
(params: { oldestDiscussionId?: number, oldestDiscussionUpdatedDate?: Date, searchTerm?: string, searchTermHasChanged?: boolean }) => Promise<Discussion[]>
The function to fetch the list of discussions from the BackEnd
(discussion: OrionChatEntity) => string
The function to format the title of discussions
(discussion: OrionChatEntity) => User[]
The function to format the participants of the discussion
(params: {discussion: OrionChatEntity, discussionId: number, messages: OrionChatMessageEntity[] }) => number
The function to determine the number of unread messages in a discussion
(params: { discussion: OrionChatEntity, discussionId: number, oldestMessageId?: number }) => Promise<Message[]>
The function to fetch the list of messages from the BackEnd
(message: OrionChatMessageEntity) => void
Callback to execute when reading a message (e.g., to save its status in the BackEnd)
(message: OrionChatMessageEntity, registerMessage: () => void) => void
Callback to execute when the user creates a new message
(discussionId?: number, oldDiscussionId?: number) => void
Callback to execute when changing the current discussion