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.
Tips
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 = undefinednumber = undefinedboolean = undefinedboolean = undefinedEvents
Orion.Chat.NewMessageSlots
OrionChatEntityOrionChatEntitybooleanOrionChatEntityPublicInstance
() => Promise<void>() => number | undefined() => HTMLElement | undefinedChatMultipleDiscussions
Props
ChatService = undefinedEvents
numberSlots
No bindingsNo bindingsOrionChatEntityNo bindingsChatService 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.UserThe user of your application. This parameter is required upon creation.
booleanDisplay the message status (read/unread)
booleanDisplay the icon for creating a new discussion in the OrionChatDiscussionList component
booleanEnable searching among discussions in the OrionChatDiscussionList component
number : 500The 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) => stringThe 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[] }) => numberThe 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) => voidCallback to execute when reading a message (e.g., to save its status in the BackEnd)
(message: OrionChatMessageEntity, registerMessage: () => void) => voidCallback to execute when the user creates a new message
(discussionId?: number, oldDiscussionId?: number) => voidCallback to execute when changing the current discussion