use CallState and CallChannelState from @mattermost/calls (#7318)

This commit is contained in:
Christopher Poile 2023-04-28 20:55:40 -04:00 committed by GitHub
parent 5dfc67dc61
commit 1ce69f20fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 40 deletions

View file

@ -47,12 +47,10 @@ import type {
Call,
CallParticipant,
CallsConnection,
ServerCallState,
ServerChannelState,
} from '@calls/types/calls';
import type {Client} from '@client/rest';
import type ClientError from '@client/rest/error';
import type {CallRecordingState, EmojiData} from '@mattermost/calls/lib/types';
import type {CallChannelState, CallRecordingState, CallState, EmojiData} from '@mattermost/calls/lib/types';
import type {IntlShape} from 'react-intl';
let connection: CallsConnection | null = null;
@ -96,7 +94,7 @@ export const loadCalls = async (serverUrl: string, userId: string) => {
} catch (error) {
return {error};
}
let resp: ServerChannelState[] = [];
let resp: CallChannelState[] = [];
try {
resp = await client.getCalls() || [];
} catch (error) {
@ -136,7 +134,7 @@ export const loadCallForChannel = async (serverUrl: string, channelId: string) =
return {error};
}
let resp: ServerChannelState;
let resp: CallChannelState;
try {
resp = await client.getCallForChannel(channelId);
} catch (error) {
@ -160,7 +158,7 @@ export const loadCallForChannel = async (serverUrl: string, channelId: string) =
return {data: {call, enabled: resp.enabled}};
};
const createCallAndAddToIds = (channelId: string, call: ServerCallState, ids: Set<string>) => {
const createCallAndAddToIds = (channelId: string, call: CallState, ids: Set<string>) => {
return {
participants: call.users.reduce((accum, cur, curIdx) => {
// Add the id to the set of UserModels we want to ensure are loaded.

View file

@ -1,16 +1,16 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import type {ServerChannelState, ApiResp} from '@calls/types/calls';
import type {CallRecordingState, CallsConfig} from '@mattermost/calls/lib/types';
import type {ApiResp} from '@calls/types/calls';
import type {CallChannelState, CallRecordingState, CallsConfig} from '@mattermost/calls/lib/types';
import type {RTCIceServer} from 'react-native-webrtc';
export interface ClientCallsMix {
getEnabled: () => Promise<Boolean>;
getCalls: () => Promise<ServerChannelState[]>;
getCallForChannel: (channelId: string) => Promise<ServerChannelState>;
getCalls: () => Promise<CallChannelState[]>;
getCallForChannel: (channelId: string) => Promise<CallChannelState>;
getCallsConfig: () => Promise<CallsConfig>;
enableChannelCalls: (channelId: string, enable: boolean) => Promise<ServerChannelState>;
enableChannelCalls: (channelId: string, enable: boolean) => Promise<CallChannelState>;
endCall: (channelId: string) => Promise<ApiResp>;
genTURNCredentials: () => Promise<RTCIceServer[]>;
startCallRecording: (callId: string) => Promise<ApiResp | CallRecordingState>;

View file

@ -90,29 +90,6 @@ export type CallParticipant = {
export type ChannelsWithCalls = Dictionary<boolean>;
export type ServerChannelState = {
channel_id: string;
enabled?: boolean;
call?: ServerCallState;
}
export type ServerUserState = {
unmuted: boolean;
raised_hand: number;
}
export type ServerCallState = {
id: string;
start_at: number;
users: string[];
states: ServerUserState[];
thread_id: string;
screen_sharing_id: string;
owner_id: string;
host_id: string;
recording: CallRecordingState;
}
export type CallsConnection = {
disconnect: () => void;
mute: () => void;
@ -143,6 +120,7 @@ export const DefaultCallsConfig: CallsConfigState = {
EnableRecordings: false,
MaxRecordingDuration: 60,
AllowScreenSharing: true,
EnableSimulcast: false,
};
export type ApiResp = {

10
package-lock.json generated
View file

@ -17,7 +17,7 @@
"@formatjs/intl-pluralrules": "5.2.1",
"@formatjs/intl-relativetimeformat": "11.2.1",
"@gorhom/bottom-sheet": "4.4.5",
"@mattermost/calls": "github:mattermost/calls-common#v0.12.0",
"@mattermost/calls": "github:mattermost/calls-common#v0.14.0",
"@mattermost/compass-icons": "0.1.36",
"@mattermost/react-native-emm": "1.3.5",
"@mattermost/react-native-network-client": "1.3.3",
@ -3391,8 +3391,8 @@
},
"node_modules/@mattermost/calls": {
"name": "@calls/common",
"version": "0.12.0",
"resolved": "git+ssh://git@github.com/mattermost/calls-common.git#02c52be3b71080023803621877ab96a7fe306fba"
"version": "0.14.0",
"resolved": "git+ssh://git@github.com/mattermost/calls-common.git#d539eb36f9549075b0a0a6578174db31297c45ae"
},
"node_modules/@mattermost/commonmark": {
"version": "0.30.1-0",
@ -24248,8 +24248,8 @@
}
},
"@mattermost/calls": {
"version": "git+ssh://git@github.com/mattermost/calls-common.git#02c52be3b71080023803621877ab96a7fe306fba",
"from": "@mattermost/calls@github:mattermost/calls-common#v0.12.0"
"version": "git+ssh://git@github.com/mattermost/calls-common.git#d539eb36f9549075b0a0a6578174db31297c45ae",
"from": "@mattermost/calls@git://github.com/mattermost/calls-common.git#v0.14.0"
},
"@mattermost/commonmark": {
"version": "0.30.1-0",

View file

@ -14,7 +14,7 @@
"@formatjs/intl-pluralrules": "5.2.1",
"@formatjs/intl-relativetimeformat": "11.2.1",
"@gorhom/bottom-sheet": "4.4.5",
"@mattermost/calls": "github:mattermost/calls-common#v0.12.0",
"@mattermost/calls": "github:mattermost/calls-common#v0.14.0",
"@mattermost/compass-icons": "0.1.36",
"@mattermost/react-native-emm": "1.3.5",
"@mattermost/react-native-network-client": "1.3.3",