Models
Users
The Users model type is used to store all chat users.
Name | Data type | Description |
---|---|---|
byId | { [userId: string]: User } | A map of all fetched users by ID |
fetching | boolean | True if currently fetching users |
current | IUser | The current logged in chat user |
Name | Data type | Description |
---|---|---|
byId | { [userId: string]: User } | A map of all fetched users by ID |
fetching | boolean | True if currently fetching users |
current | IUser | The current logged in chat user |
Name | Arguments | Description |
---|---|---|
get | id: string - the user id | Get a specific user by their user id |
all | N/A | Get all users as an array |
others | N/A | Get all users except the current user |
fetch | id: string - the user id to fetch from the api | Fetch the user via the API. If the user is already in the store, that user is returned and no API call is made. |
Name | Arguments | Description |
---|---|---|
createOrUpdate | data: FUserFragment - the user to create or update (store only) | Updates the user in the store. If user doesn’t exist, a new one is created. NOTE: this does not create the user in the database. |
reset | N/A | Resets store to initial state |
User
The User model type defines a single instance of a user
Name | Data type | Description |
---|---|---|
id | string | The unique user id |
username | string | User’s username |
display_name | string|undefined | User’s display name |
description | string|undefined | User’s bio and/or details |
created_at | Date | The date the user was created |
updated_at | Date | The date the user was last updated |
image | string|undefined | URL or base64 encoded string of the user’s avatar |
last_seen | Date | The last time a user was active |
status | OnlineStatus | The current status of the user |
Name | Data type | Description |
---|---|---|
id | string | The unique user id |
username | string | User’s username |
display_name | string|undefined | User’s display name |
description | string|undefined | User’s bio and/or details |
created_at | Date | The date the user was created |
updated_at | Date | The date the user was last updated |
image | string|undefined | URL or base64 encoded string of the user’s avatar |
last_seen | Date | The last time a user was active |
status | OnlineStatus | The current status of the user |
Name | Arguments | Description |
---|---|---|
dun | N/A | Display name of the user. Uses |
isCurrent | N/A | Returns true if the user is the current logged in user |
blocked | N/A | Returns true if the user is blocked |
lastSeenFormat | N/A | Helper function for returning the last seen date in a string format |
Chats
The Chats model type is used to store all the chats: DMs and Channels
Name | Data type | Description |
---|---|---|
byId | { [chatId: string]: Chat } | A map of all fetched chats by ID |
fetching | boolean | True if currently fetching chats |
Name | Data type | Description |
---|---|---|
byId | { [chatId: string]: Chat } | A map of all fetched chats by ID |
fetching | boolean | True if currently fetching chats |
Name | Arguments | Description |
---|---|---|
get | id: string - chat id | Get a specific chat by the chat ID |
fetch | id: string - the chat id to fetch from the api | Fetch the chat via the API. If the chat already exists in the store, that chat is returned and no API call is made. |
Name | Arguments | Description |
---|---|---|
createOrUpdate | data: FChatFragment - the chat to create or update (store only) | Updates the chat in the store. If chat doesn’t exist, a new one is created. NOTE: this does not create the chat in the database. |
create | input: CreateGroupInput - group chat to create | Sends api request to create a new group or channel |
reset | N/A | Resets store to initial state |
Chat
The Chat model type is used to define a specific chat, whether DM or channel
Name | Data type | Description |
---|---|---|
id | string | The unique chat id |
created_at | Date | The date the chat was created |
updated_at | Date | The date the chat was last updated |
members | Member[] | A list of members that belong to the chat |
kind | ChatType | The type of chat |
name | string|undefined | The name of chat |
description | string|undefined | The description of chat |
image | string|undefined | URL or base64 encoded string of the chat |
_private | boolean | True if a private chat. If false, any user can join the channel. |
last_message | Message|undefined | The last sent message of the chat |
joining | boolean|undefined | True if current user is in the process of joining the chat |
unread_count | number | The number of unread messages by the user of this chat |
users_typing | User[] | The users that are currently typing |
messages | MessageList | List of messages |
outgoing | Message[]|undefined | Messages that are currently being sent |
invites | User[]|undefined | Users that have been invited to the channel, but not yet joined |
Name | Data type | Description |
---|---|---|
id | string | The unique chat id |
created_at | Date | The date the chat was created |
updated_at | Date | The date the chat was last updated |
members | Member[] | A list of members that belong to the chat |
kind | ChatType | The type of chat |
name | string|undefined | The name of chat |
description | string|undefined | The description of chat |
image | string|undefined | URL or base64 encoded string of the chat |
_private | boolean | True if a private chat. If false, any user can join the channel. |
last_message | Message|undefined | The last sent message of the chat |
joining | boolean|undefined | True if current user is in the process of joining the chat |
unread_count | number | The number of unread messages by the user of this chat |
users_typing | User[] | The users that are currently typing |
messages | MessageList | List of messages |
outgoing | Message[]|undefined | Messages that are currently being sent |
invites | User[]|undefined | Users that have been invited to the channel, but not yet joined |
Name | Arguments | Description |
---|---|---|
membership | N/A | Returns the IMember object of the current user if the current user is a member of this chat. |
is_member | N/A | Returns true if the current user is a member of this chat |
friend | N/A | Returns the dun of the other user if this is a DM. |
display_name | N/A | Returns the name of the chat if a |
initials | N/A | Returns the initials of the display_name |
isGroup | N/A | Returns true if this chat is a group |
isDM | N/A | Returns true if this chat is a DM |
activeMembers | N/A | Returns the list of members in this chat |
typing | N/A | Returns a user friendly string representing currently typing users |
Name | Arguments | Description |
---|---|---|
toggleJoin | N/A | If the current user is not a member, they are added as a member of the chat. Otherwise, they are removed. (store-only) |
join | N/A | Adds the current user to chat and persists |
leave | N/A | Removes the current user from the chat and persists |
markRead | N/A | Mark all the messages in the chat to read for the current user |
sendMessage | SendMessageInput | Send a message as the current message |
addInvite | IUser | Adds an invite to the store |
addMember | IMember | Adds a member to the store |
startTyping | N/A | Sends indicator to chat server to initiate typing status |
finishTyping | N/A | Sends indicator to chat server to complete typing status |
deleteMessage | id: string | Deletes a message permanently |
updateMessage | message: IMessage, input: SendMessageInput | Updates a message |
Messages
The Messages model type is used to store all the messages
Name | Data type | Description |
---|---|---|
byId | { [chatId: string]: Message } | A map of all fetched messages by ID |
fetching | boolean | True if currently fetching messages |
Name | Data type | Description |
---|---|---|
byId | { [chatId: string]: Message } | A map of all fetched messages by ID |
fetching | boolean | True if currently fetching messages |
Name | Arguments | Description |
---|---|---|
get | id: string - message id | Get a specific message by the message ID |
fetch | id: string - ID of the message to fetch from the api | Fetch the message via the API. If the message already exists in the store, that message is returned and no API call is made. |
Name | Arguments | Description |
---|---|---|
createOrUpdate | data: FMessageFragment - the message to create or update (store only) | Updates the message in the store. If message doesn’t exist, a new one is created. NOTE: this does not create the message in the database. |
reset | N/A | Resets store to initial state |
remove | id: string - id of message to be removed | Removes the message from the store |
Message
The Message model type is used to define a specific message
Name | Data type | Description |
---|---|---|
id | string | The unique message id |
created_at | Date | The date the message was created |
updated_at | Date | The date the message was last updated |
text | string|undefined | The textual portion of the message |
user | User | The sender |
parent_id | string|undefined | The id of the parent message in the event this message is within a thread |
chat_id | string | Id of the chat |
replies | Message[]|undefined | The array of replies to this message |
reply_count | number | Number of replies |
reactions | string[]|undefined | Message reactions and the users they belong to |
attachments | Attachment[]|undefined | The attachments sent with the message |
mentions | Mention[]|undefined | The message mentions |
status | string|undefined | sending or sent |
favorite | boolean | True if current user marked as favorite |
system | SystemMessageType|undefined | System message type |
Name | Data type | Description |
---|---|---|
id | string | The unique message id |
created_at | Date | The date the message was created |
updated_at | Date | The date the message was last updated |
text | string|undefined | The textual portion of the message |
user | User | The sender |
parent_id | string|undefined | The id of the parent message in the event this message is within a thread |
chat_id | string | Id of the chat |
replies | Message[]|undefined | The array of replies to this message |
reply_count | number | Number of replies |
reactions | string[]|undefined | Message reactions and the users they belong to |
attachments | Attachment[]|undefined | The attachments sent with the message |
mentions | Mention[]|undefined | The message mentions |
status | string|undefined | sending or sent |
favorite | boolean | True if current user marked as favorite |
system | SystemMessageType|undefined | System message type |
Name | Arguments | Description |
---|---|---|
displayTimestamp | N/A | User friendly string interpretation of timestamp using the
|
markdown | N/A | Get the text parsed as markdown |
Name | Arguments | Description |
---|---|---|
react | string - the reaction string | Add a reaction from the current user |
toggleFavorite | N/A | Mark message as favorite for the current user if not already favorited. Otherwise, unfavorite. |
fetchReplies | N/A | Fetch all the replies for this message |
addReply | N/A | Add a new reply to the the replies (store-only) |