MM-52653 - Calls: Attach call to existing thread on /call start (#7338)
* send rootId when starting a call from a thread * allow join to start calls in threads and with thread titles
This commit is contained in:
parent
dbd943ab8d
commit
81dd44ae09
4 changed files with 16 additions and 9 deletions
|
|
@ -166,7 +166,7 @@ export default function SendHandler({
|
|||
|
||||
const sendCommand = useCallback(async () => {
|
||||
if (value.trim().startsWith('/call')) {
|
||||
const {handled, error} = await handleCallsSlashCommand(value.trim(), serverUrl, channelId, currentUserId, intl);
|
||||
const {handled, error} = await handleCallsSlashCommand(value.trim(), serverUrl, channelId, rootId, currentUserId, intl);
|
||||
if (handled) {
|
||||
setSendingMessage(false);
|
||||
clearDraft();
|
||||
|
|
|
|||
|
|
@ -208,6 +208,7 @@ export const joinCall = async (
|
|||
userId: string,
|
||||
hasMicPermission: boolean,
|
||||
title?: string,
|
||||
rootId?: string,
|
||||
): Promise<{ error?: unknown; data?: string }> => {
|
||||
// Edge case: calls was disabled when app loaded, and then enabled, but app hasn't
|
||||
// reconnected its websocket since then (i.e., hasn't called batchLoadCalls yet)
|
||||
|
|
@ -226,7 +227,7 @@ export const joinCall = async (
|
|||
try {
|
||||
connection = await newConnection(serverUrl, channelId, () => {
|
||||
myselfLeftCall();
|
||||
}, setScreenShareURL, hasMicPermission, title);
|
||||
}, setScreenShareURL, hasMicPermission, title, rootId);
|
||||
} catch (error) {
|
||||
await forceLogoutIfNecessary(serverUrl, error);
|
||||
return {error};
|
||||
|
|
@ -417,7 +418,7 @@ export const stopCallRecording = async (serverUrl: string, callId: string) => {
|
|||
};
|
||||
|
||||
// handleCallsSlashCommand will return true if the slash command was handled
|
||||
export const handleCallsSlashCommand = async (value: string, serverUrl: string, channelId: string, currentUserId: string, intl: IntlShape):
|
||||
export const handleCallsSlashCommand = async (value: string, serverUrl: string, channelId: string, rootId: string, currentUserId: string, intl: IntlShape):
|
||||
Promise<{ handled?: boolean; error?: string }> => {
|
||||
const tokens = value.split(' ');
|
||||
if (tokens.length < 2 || tokens[0] !== '/call') {
|
||||
|
|
@ -438,12 +439,14 @@ export const handleCallsSlashCommand = async (value: string, serverUrl: string,
|
|||
};
|
||||
}
|
||||
const title = tokens.length > 2 ? tokens.slice(2).join(' ') : undefined;
|
||||
await leaveAndJoinWithAlert(intl, serverUrl, channelId, title);
|
||||
await leaveAndJoinWithAlert(intl, serverUrl, channelId, title, rootId);
|
||||
return {handled: true};
|
||||
}
|
||||
case 'join':
|
||||
await leaveAndJoinWithAlert(intl, serverUrl, channelId);
|
||||
case 'join': {
|
||||
const title = tokens.length > 2 ? tokens.slice(2).join(' ') : undefined;
|
||||
await leaveAndJoinWithAlert(intl, serverUrl, channelId, title, rootId);
|
||||
return {handled: true};
|
||||
}
|
||||
case 'leave':
|
||||
if (getCurrentCall()?.channelId === channelId) {
|
||||
await leaveCall();
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ export const leaveAndJoinWithAlert = async (
|
|||
joinServerUrl: string,
|
||||
joinChannelId: string,
|
||||
title?: string,
|
||||
rootId?: string,
|
||||
) => {
|
||||
let leaveChannelName = '';
|
||||
let joinChannelName = '';
|
||||
|
|
@ -132,13 +133,13 @@ export const leaveAndJoinWithAlert = async (
|
|||
id: 'mobile.leave_and_join_confirmation',
|
||||
defaultMessage: 'Leave & Join',
|
||||
}),
|
||||
onPress: () => doJoinCall(joinServerUrl, joinChannelId, joinChannelIsDMorGM, newCall, intl, title),
|
||||
onPress: () => doJoinCall(joinServerUrl, joinChannelId, joinChannelIsDMorGM, newCall, intl, title, rootId),
|
||||
style: 'cancel',
|
||||
},
|
||||
],
|
||||
);
|
||||
} else {
|
||||
doJoinCall(joinServerUrl, joinChannelId, joinChannelIsDMorGM, newCall, intl, title);
|
||||
doJoinCall(joinServerUrl, joinChannelId, joinChannelIsDMorGM, newCall, intl, title, rootId);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -149,6 +150,7 @@ const doJoinCall = async (
|
|||
newCall: boolean,
|
||||
intl: IntlShape,
|
||||
title?: string,
|
||||
rootId?: string,
|
||||
) => {
|
||||
const {formatMessage} = intl;
|
||||
|
||||
|
|
@ -197,7 +199,7 @@ const doJoinCall = async (
|
|||
const hasPermission = await hasMicrophonePermission();
|
||||
setMicPermissionsGranted(hasPermission);
|
||||
|
||||
const res = await joinCall(serverUrl, channelId, user.id, hasPermission, title);
|
||||
const res = await joinCall(serverUrl, channelId, user.id, hasPermission, title, rootId);
|
||||
if (res.error) {
|
||||
const seeLogs = formatMessage({id: 'mobile.calls_see_logs', defaultMessage: 'See server logs'});
|
||||
errorAlert(res.error?.toString() || seeLogs, intl);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ export async function newConnection(
|
|||
setScreenShareURL: (url: string) => void,
|
||||
hasMicPermission: boolean,
|
||||
title?: string,
|
||||
rootId?: string,
|
||||
) {
|
||||
let peer: RTCPeer | null = null;
|
||||
let stream: MediaStream;
|
||||
|
|
@ -323,6 +324,7 @@ export async function newConnection(
|
|||
ws.send('join', {
|
||||
channelID,
|
||||
title,
|
||||
threadID: rootId,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue