Skip to content

Commit

Permalink
Fix initialization for standalone client (#497)
Browse files Browse the repository at this point in the history
  • Loading branch information
streamer45 authored Aug 21, 2023
1 parent ab8863b commit aa8f496
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 9 additions & 2 deletions standalone/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ async function fetchChannelData(store: Store, channelID: string) {
);

if (!resp.call) {
throw new Error('call missing from response');
// This is expected if the client is starting the call.
return;
}

store.dispatch({
Expand Down Expand Up @@ -353,7 +354,13 @@ export default async function init(cfg: InitConfig) {
const theme = getTheme(store.getState());
applyTheme(theme);

await cfg.initCb(store, theme, channelID);
try {
await cfg.initCb(store, theme, channelID);
} catch (err) {
logErr('initCb failed', err);
window.callsClient?.destroy();
return;
}

logDebug(`${cfg.name} init completed in ${Math.round(performance.now() - initStartTime)}ms`);
}
Expand Down
6 changes: 5 additions & 1 deletion standalone/src/recording/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {Theme} from 'mattermost-redux/types/themes';
import {getCurrentUserId} from 'mattermost-webapp/packages/mattermost-redux/src/selectors/entities/users';
import {logErr} from 'plugin/log';
import {pluginId} from 'plugin/manifest';
import {voiceConnectedProfilesInChannel} from 'plugin/selectors';
import {voiceConnectedProfilesInChannel, voiceChannelCallStartAt} from 'plugin/selectors';
import {Store} from 'plugin/types/mattermost-webapp';
import {getProfilesByIds, getPluginPath, fetchTranslationsFile, setCallsGlobalCSSVars} from 'plugin/utils';
import React from 'react';
Expand Down Expand Up @@ -71,6 +71,10 @@ async function initRecordingStore(store: Store, channelID: string) {
}

async function initRecording(store: Store, theme: Theme, channelID: string) {
if (!voiceChannelCallStartAt(store.getState(), channelID)) {
throw new Error('call is missing from store');
}

await store.dispatch({
type: VOICE_CHANNEL_USER_CONNECTED,
data: {
Expand Down

0 comments on commit aa8f496

Please sign in to comment.