From a1601b039e5ff89b5403f11766aee4dab59c91fe Mon Sep 17 00:00:00 2001 From: Warrick Corfe-Tan Date: Wed, 22 Sep 2021 17:04:15 +1000 Subject: [PATCH] Adding call to convo header menu --- ts/components/session/ActionsPanel.tsx | 2 +- .../session/menu/ConversationHeaderMenu.tsx | 2 + ts/components/session/menu/Menu.tsx | 38 +++++++++++++++++++ ts/models/conversation.ts | 2 +- ts/window.d.ts | 1 + 5 files changed, 43 insertions(+), 2 deletions(-) diff --git a/ts/components/session/ActionsPanel.tsx b/ts/components/session/ActionsPanel.tsx index 6d750d921..80b397f73 100644 --- a/ts/components/session/ActionsPanel.tsx +++ b/ts/components/session/ActionsPanel.tsx @@ -289,7 +289,7 @@ export const ActionsPanel = () => { - +
diff --git a/ts/components/session/menu/ConversationHeaderMenu.tsx b/ts/components/session/menu/ConversationHeaderMenu.tsx index 4581cfd00..144bd4213 100644 --- a/ts/components/session/menu/ConversationHeaderMenu.tsx +++ b/ts/components/session/menu/ConversationHeaderMenu.tsx @@ -15,6 +15,7 @@ import { getNotificationForConvoMenuItem, getPinConversationMenuItem, getRemoveModeratorsMenuItem, + getStartCallMenuItem, getUpdateGroupNameMenuItem, } from './Menu'; import _ from 'lodash'; @@ -53,6 +54,7 @@ const ConversationHeaderMenu = (props: PropsConversationHeaderMenu) => { return ( + {getStartCallMenuItem(conversationId)} {getDisappearingMenuItem(isPublic, isKickedFromGroup, left, isBlocked, conversationId)} {getNotificationForConvoMenuItem({ isKickedFromGroup, diff --git a/ts/components/session/menu/Menu.tsx b/ts/components/session/menu/Menu.tsx index 29e3988f2..2491dc454 100644 --- a/ts/components/session/menu/Menu.tsx +++ b/ts/components/session/menu/Menu.tsx @@ -29,6 +29,7 @@ import { import { SessionButtonColor } from '../SessionButton'; import { getTimerOptions } from '../../../state/selectors/timerOptions'; import { ToastUtils } from '../../../session/utils'; +import { getConversationById } from '../../../data/data'; const maxNumberOfPinnedConversations = 5; @@ -318,6 +319,43 @@ export function getMarkAllReadMenuItem(conversationId: string): JSX.Element | nu ); } +export function getStartCallMenuItem(conversationId: string): JSX.Element | null { + // TODO: possibly conditionally show options? + const callOptions = [ + { + name: 'Video call', + value: 'video-call', + }, + { + name: 'Audio call', + value: 'audio-call', + }, + ]; + + return ( + + {callOptions.map(item => ( + { + // TODO: either pass param to callRecipient or call different call methods based on item selected. + const convo = await getConversationById(conversationId); + if (convo) { + // window?.libsession?.Utils.CallManager.USER_callRecipient( + // '054774a456f15c7aca42fe8d245983549000311aaebcf58ce246250c41fe227676' + // ); + window?.libsession?.Utils.CallManager.USER_callRecipient(convo.id); + convo.callState = 'connecting'; + } + }} + > + {item.name} + + ))} + + ); +} + export function getDisappearingMenuItem( isPublic: boolean | undefined, isKickedFromGroup: boolean | undefined, diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index ac79ac978..1fa9609a6 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -184,7 +184,7 @@ export class ConversationModel extends Backbone.Model { public markRead: (newestUnreadDate: number, providedOptions?: any) => Promise; public initialPromise: any; - public callState: 'incoming' | 'connecting' | 'ongoing' | 'none' | undefined; + public callState: 'offering' | 'incoming' | 'connecting' | 'ongoing' | 'none' | undefined; private typingRefreshTimer?: NodeJS.Timeout | null; private typingPauseTimer?: NodeJS.Timeout | null; diff --git a/ts/window.d.ts b/ts/window.d.ts index ff6c7ba51..833e929ec 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -83,5 +83,6 @@ declare global { callWorker: (fnName: string, ...args: any) => Promise; setStartInTray: (val: boolean) => Promise; getStartInTray: () => Promise; + libsession: any; } }