Shared types
Shared types are used in the props that are given to several components.
The Markup
type holds markup that can be used as template output, but can't be processed like strings or other basic value types.
Represents a user
1type User = {2 id: string;3 name: string;4 firstName: string;5 photoUrl: string | nil;6 role: string | nil;7 locale: string | nil;8 isMe: boolean;9 custom: { [key: string]: string };10};
A message in a conversation
1type Message = {2 type: 'UserMessage' | 'SystemMessage';3 sender: User | nil; // nil for system messages4 previousMessage: Message | nil;5 conversation: Conversation;6 isWelcomeMessage: boolean;7 timestamp: number | nil; // nil for welcome messages8 editedAt: number | nil; // timestamp at which the message was edited9 hasReferencedMessage: boolean;10 referencedMessage: Message;11 // Whether this is a message sent via email, that spans multiple lines.12 // If this is true, it might be useful to indicate that it's an email message, in case there is any unexpected text or markup inserted by the email client.13 isLongEmailMessage: boolean;14 custom: { [key: string]: string };15 canReact: boolean; // Whether the current user is allowed to add reactions to this message16 reactions: Reaction[] | nil; // Emoji reactions, only set for user messages17 body: {18 type: 'text' | 'file' | 'location' | 'typing-indicator';19 hasThumbnail: boolean;20 // The following fields are only set if the body type is "text":21 rawText: string | nil;22 formattedText: Markup | nil;23 links: string[] | nil;24 // The following fields are only set if the body type is "file":25 isVoiceMessage: boolean | nil; // Whether the file is a voice message26 recordingDuration: number | nil; // Voice message recording duration in seconds27 thumbnailError: boolean | nil; // Whether there was an error displaying the thumbnail of this file28 file: File | nil;29 // The following fields are only set if the body type is "file":30 location: [number, number]; // The latitude and longitude.31 };32};
An emoji reaction on a message
1type Reaction: {2 emoji: string,3 iReacted: boolean, // Whether the current user has placed this rreaction4 numReactions: number // the number of users who reacted with this emoji5}
A file attached to a message
1type File = {2 url: string;3 filename: string;4 formattedFilename?: Markup;5 // The file's size in bytes6 size: number;7 // For images or videos, to show thumbnails at the correct size before loading to prevent content shift on slow connections8 dimensions?: { width: number; height: number } | nil;9 type: 'image' | 'video' | 'audio' | 'other';10};
1type Conversation = {2 id: string;3 rawSubject: string | nil;4 formattedSubject: Markup | nil;5 photoUrl: string | nil;6 custom: { [key: string]: string };7 participants: User[];8 // Participants in the conversation, excluding the current user9 otherParticipants: User[];10 isGroupChat: boolean; // true if this conversation has more than 2 participants or if it has no participants (meaning everyone is a guest)11 me: User;12};