diff --git a/src/ui/pages/ChatPage.tsx b/src/ui/pages/ChatPage.tsx index dee4c47..9f8eaeb 100644 --- a/src/ui/pages/ChatPage.tsx +++ b/src/ui/pages/ChatPage.tsx @@ -314,6 +314,28 @@ class ChatPage extends React.Component { } } + /** + * Creates a new conversation. + * + * @param name The name of the conversation. + * @private + */ + private async createConversation(name: string = "Cool Conversation"): Promise { + // Get the selected channel. + const selected = this.state.selectedChannel; + if (!selected) throw new Error("No channel selected."); + + // Get the credentials. + const { token } = getCredentials(); + // Create the conversation. + const body = JSON.stringify({ + name, channelId: selected.id + }); + await fetch(newCall(`conversation`), { + method: "POST", body, headers: { Authorization: token } + }); + } + /** * Sets the width of the text input box. */ @@ -353,7 +375,8 @@ class ChatPage extends React.Component {