From 2a9b090ad62c2d157e06c978ba4cbc663f7c550f Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Fri, 9 Apr 2021 19:06:12 -0400 Subject: moved createChannel to messages util --- src/utils/messages.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/utils/messages.ts') diff --git a/src/utils/messages.ts b/src/utils/messages.ts index 49033226..dd29f317 100644 --- a/src/utils/messages.ts +++ b/src/utils/messages.ts @@ -123,3 +123,20 @@ export const getChatToken = async () => { console.log(err); } }; + +export const createChannel = async ( + loggedInUser: string, + id: string, + chatClient: any, +) => { + try { + const channel = chatClient.channel('messaging', { + members: [loggedInUser, id], + }); + await channel.watch(); + return channel; + } catch (error) { + console.log(error); + throw error; + } +}; -- cgit v1.2.3-70-g09d2