From 2a1689009ad67569a7ff33d4fe91b79c7d4406ec Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Tue, 9 Aug 2022 09:43:12 -0400 Subject: [PATCH] Extract state event capabilities into a variable --- src/matrix-utils.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/matrix-utils.ts b/src/matrix-utils.ts index 68680f2..ed3cde3 100644 --- a/src/matrix-utils.ts +++ b/src/matrix-utils.ts @@ -77,7 +77,16 @@ export async function initMatroskaClient( if (!userId) throw new Error("User ID must be supplied"); if (!deviceId) throw new Error("Device ID must be supplied"); - // These are all the to-device event types the app uses + // These are all the event types the app uses + const sendState = [ + { eventType: EventType.GroupCallPrefix }, + { eventType: EventType.GroupCallMemberPrefix, stateKey: userId }, + ]; + const receiveState = [ + { eventType: EventType.RoomMember }, + { eventType: EventType.GroupCallPrefix }, + { eventType: EventType.GroupCallMemberPrefix }, + ]; const sendRecvToDevice = [ EventType.CallInvite, EventType.CallCandidates, @@ -98,15 +107,8 @@ export async function initMatroskaClient( const client = createRoomWidgetClient( new WidgetApi(widgetId, new URL(parentUrl).origin), { - sendState: [ - { eventType: EventType.GroupCallPrefix }, - { eventType: EventType.GroupCallMemberPrefix, stateKey: userId }, - ], - receiveState: [ - { eventType: EventType.RoomMember }, - { eventType: EventType.GroupCallPrefix }, - { eventType: EventType.GroupCallMemberPrefix }, - ], + sendState, + receiveState, sendToDevice: sendRecvToDevice, receiveToDevice: sendRecvToDevice, turnServers: true,