From ac89dbb4d077373c6eabc46290012f5fe8062e39 Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Sun, 26 Apr 2026 13:45:33 +0530 Subject: [PATCH] update element call and widget api --- package-lock.json | 16 +++++++-------- package.json | 4 ++-- src/app/hooks/useCallEmbed.ts | 3 ++- src/app/plugins/call/CallEmbed.ts | 33 +++++++++++++++++++++++++++---- src/app/plugins/call/types.ts | 2 ++ 5 files changed, 43 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 399f03a92..3db69f340 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,7 +44,7 @@ "linkify-react": "4.3.2", "linkifyjs": "4.3.2", "matrix-js-sdk": "38.2.0", - "matrix-widget-api": "1.13.0", + "matrix-widget-api": "1.16.1", "millify": "6.1.0", "pdfjs-dist": "4.2.67", "prismjs": "1.30.0", @@ -66,7 +66,7 @@ "ua-parser-js": "1.0.35" }, "devDependencies": { - "@element-hq/element-call-embedded": "0.16.3", + "@element-hq/element-call-embedded": "0.19.1", "@esbuild-plugins/node-globals-polyfill": "0.2.3", "@rollup/plugin-inject": "5.0.3", "@rollup/plugin-wasm": "6.1.1", @@ -1652,9 +1652,9 @@ } }, "node_modules/@element-hq/element-call-embedded": { - "version": "0.16.3", - "resolved": "https://registry.npmjs.org/@element-hq/element-call-embedded/-/element-call-embedded-0.16.3.tgz", - "integrity": "sha512-OViKJonDaDNVBUW9WdV9mk78/Ruh34C7XsEgt3O8D9z+64C39elbIgllHSoH5S12IRlv9RYrrV37FZLo6QWsDQ==", + "version": "0.19.1", + "resolved": "https://registry.npmjs.org/@element-hq/element-call-embedded/-/element-call-embedded-0.19.1.tgz", + "integrity": "sha512-RDZY3P3LTx10ACaGhzkwh2+boNB3x54zHF/7v/cCyoQlAVfEYMhgMEb4CRTwJFwwYFe1r++6Higa0A0G5XxZ8Q==", "dev": true }, "node_modules/@emotion/hash": { @@ -8674,9 +8674,9 @@ } }, "node_modules/matrix-widget-api": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/matrix-widget-api/-/matrix-widget-api-1.13.0.tgz", - "integrity": "sha512-+LrvwkR1izL4h2euX8PDrvG/3PZZDEd6As+lmnR3jAVwbFJtU5iTnwmZGnCca9ddngCvXvAHkcpJBEPyPTZneQ==", + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/matrix-widget-api/-/matrix-widget-api-1.16.1.tgz", + "integrity": "sha512-oCfTV4xNPo02qIgveqdkIyKQjOPpsjhF3bmJBotHrhr8TsrhVa7kx8PtuiUPnQTjz0tdBle7falR2Fw8VKsedw==", "license": "Apache-2.0", "dependencies": { "@types/events": "^3.0.0", diff --git a/package.json b/package.json index ba2cd751e..5046f47f9 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "linkify-react": "4.3.2", "linkifyjs": "4.3.2", "matrix-js-sdk": "38.2.0", - "matrix-widget-api": "1.13.0", + "matrix-widget-api": "1.16.1", "millify": "6.1.0", "pdfjs-dist": "4.2.67", "prismjs": "1.30.0", @@ -78,7 +78,7 @@ "ua-parser-js": "1.0.35" }, "devDependencies": { - "@element-hq/element-call-embedded": "0.16.3", + "@element-hq/element-call-embedded": "0.19.1", "@esbuild-plugins/node-globals-polyfill": "0.2.3", "@rollup/plugin-inject": "5.0.3", "@rollup/plugin-wasm": "6.1.1", diff --git a/src/app/hooks/useCallEmbed.ts b/src/app/hooks/useCallEmbed.ts index 4a354d57e..b50dad91a 100644 --- a/src/app/hooks/useCallEmbed.ts +++ b/src/app/hooks/useCallEmbed.ts @@ -48,7 +48,7 @@ export const createCallEmbed = ( const ongoing = MatrixRTCSession.sessionMembershipsForRoom(room, rtcSession.sessionDescription).length > 0; - const intent = CallEmbed.getIntent(dm, ongoing); + const intent = CallEmbed.getIntent(dm, ongoing, pref?.video); const widget = CallEmbed.getWidget(mx, room, intent, themeKind); const controlState = pref && new CallControlState(pref.microphone, pref.video, pref.sound); @@ -101,6 +101,7 @@ export const useCallJoined = (embed?: CallEmbed): boolean => { export const useCallHangupEvent = (embed: CallEmbed, callback: () => void) => { useClientWidgetApiEvent(embed.call, ElementWidgetActions.HangupCall, callback); + useClientWidgetApiEvent(embed.call, ElementWidgetActions.Close, callback); }; export const useCallMemberSoundSync = (embed: CallEmbed) => { diff --git a/src/app/plugins/call/CallEmbed.ts b/src/app/plugins/call/CallEmbed.ts index 870466769..c1deb0d13 100644 --- a/src/app/plugins/call/CallEmbed.ts +++ b/src/app/plugins/call/CallEmbed.ts @@ -47,12 +47,33 @@ export class CallEmbed { private readonly disposables: Array<() => void> = []; - static getIntent(dm: boolean, ongoing: boolean): ElementCallIntent { - if (ongoing) { - return dm ? ElementCallIntent.JoinExistingDM : ElementCallIntent.JoinExisting; + static getIntent(dm: boolean, ongoing: boolean, video?: boolean): ElementCallIntent { + if (dm && ongoing) { + return video ? ElementCallIntent.JoinExistingDM : ElementCallIntent.JoinExistingDMVoice; + } + if (dm) { + return video ? ElementCallIntent.StartCallDM : ElementCallIntent.StartCallDMVoice; } - return dm ? ElementCallIntent.StartCallDM : ElementCallIntent.StartCall; + if (ongoing) { + return video ? ElementCallIntent.JoinExisting : ElementCallIntent.JoinExistingVoice; + } + return video ? ElementCallIntent.StartCall : ElementCallIntent.StartCallVoice; + } + + static dmCall(intent: ElementCallIntent): boolean { + return ( + intent === ElementCallIntent.JoinExistingDM || + intent === ElementCallIntent.JoinExistingDMVoice || + intent === ElementCallIntent.StartCallDM || + intent === ElementCallIntent.StartCallDMVoice + ); + } + + static startingDMCall(intent: ElementCallIntent): boolean { + return ( + intent === ElementCallIntent.StartCallDM || intent === ElementCallIntent.StartCallDMVoice + ); } static getWidget( @@ -81,7 +102,11 @@ export class CallEmbed { perParticipantE2EE: room.hasEncryptionStateEvent().toString(), lang: 'en-EN', theme: themeKind, + header: 'none', }); + if (CallEmbed.startingDMCall(intent)) { + params.append('sendNotificationType', 'ring'); + } const widgetUrl = new URL( `${trimTrailingSlash(import.meta.env.BASE_URL)}/public/element-call/index.html`, diff --git a/src/app/plugins/call/types.ts b/src/app/plugins/call/types.ts index 4f4fc3817..89a9e61d4 100644 --- a/src/app/plugins/call/types.ts +++ b/src/app/plugins/call/types.ts @@ -1,6 +1,8 @@ export enum ElementCallIntent { StartCall = 'start_call', JoinExisting = 'join_existing', + StartCallVoice = 'start_call_voice', + JoinExistingVoice = 'join_existing_voice', StartCallDM = 'start_call_dm', JoinExistingDM = 'join_existing_dm', StartCallDMVoice = 'start_call_dm_voice',