-
-
Notifications
You must be signed in to change notification settings - Fork 506
Adds Element Call support, call UI elements, and rudimentary widget support #2335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
93a1401
b59a5ac
8baa3a2
e1a080e
9b23c75
8bd812b
c413396
e2c97f8
b4f67ce
ca7691d
f39a262
3403ade
a540c86
cccf963
d82e49a
c367c90
b88da57
5f0ca6a
cc88733
99e55b3
9c5fde3
eba9670
38ad5e3
0106fab
2c8ae96
28f5d8a
0b6a7c7
9d352de
1629341
9b6bfea
232fbc5
8d285d4
cb9e4ff
14206db
f76641b
fd1ccc7
5a5f144
d602631
fd0fa3c
589b318
8f87690
1ac5b3d
1a3b10e
9a3fc59
0fe90e5
7a03b91
6ad8b47
7ebf26e
79b4303
40a25aa
0fb5ffc
39e7de3
5ae8064
02cb7ea
7beb841
5677042
6d4b37f
1573353
2f980a7
c7ea3f7
a4af96b
f7fb4bc
c8790a5
6691467
39d4eed
d6ffac7
b5ca54d
1e8a69f
e766640
8700fe8
4779b09
b4d9828
ec74142
a555190
7ce3b40
8c6a626
96be8e1
8038c2a
7c6c1f5
93fbbec
de1a629
a2a83fc
7f8aeb3
c64dbb0
7808adb
79647c5
3dcfde4
2e0218c
2841386
b40ddf0
9cb7051
5ee3897
4083bbb
d11bdb2
a5a8f28
824be5b
9e919ea
3fcf2fe
abe79ce
c05421e
1bd593b
8b50ac1
43ce6f0
8b2fa10
0be5fb9
a690dbd
6714300
eea8ffe
807c90e
4293538
00ac8f6
ae9cc7a
1cdc068
9ae7c31
cd23305
a1c0b79
da3d20d
cde0d5f
1b89831
6601c47
f28a3a1
d488c24
5ab0b39
f3612e2
4486ef1
59a936b
74c883d
7043376
af455a5
3e3d686
1e44557
e688c19
dabe7f7
d9c0c85
6e33c8e
7ef3340
0b70ce7
7dcd43c
e5505cd
3bd7588
5481595
c6ceb3f
19f1df7
07a980a
67fbf94
a81492c
023a23d
0db52c2
cd0d4c9
395a24f
f262f54
e4ce4da
ff02c46
4c8ab4e
d3ec9fa
c108295
d54bc2c
9b3c6e7
27196cb
1871f70
9302003
b18f636
65ff5e3
b6afe3b
03cbecc
e220387
872e9a2
0b6009a
8b22573
3818671
f2f98a6
0ef9c56
f842356
9499289
7d26601
99576a2
f3c0aeb
22903c9
108eb60
1a82196
bf131f7
df84eb1
335df8d
18ea2d2
9b98083
0bd42a3
923982e
0e332d6
c99112b
3e6d55f
78dcdfd
39b20c7
4225282
e3f1697
6edee72
153d7d1
73c17d3
e42a617
e78d1da
7228c2e
02ac70a
daadbe4
e1146b1
a5a9e72
3b76787
8dfc3aa
0d2f76e
2575d77
5d22b28
8e4f310
4d14eb9
3f2c2af
9f749d1
b08fa60
7a169fc
f74feec
aca2a40
b46c9ed
dd158fa
e6e751d
6b3c9df
c675131
a2c8097
9be2a94
4403eac
7712e34
2081539
12e4ba9
78c3850
6d0e8b7
7e948f0
40a2277
2869735
eaf70fb
efc77ce
f407905
79fab78
ca2c868
92e24e5
5a25da4
235bb63
77f8a04
4be7042
b91a9d7
fb9ca31
e504a9e
528cbc5
51cfd72
141f148
a299e9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |||||
| "scripts": { | ||||||
| "start": "vite", | ||||||
| "build": "vite build", | ||||||
| "preview": "vite preview", | ||||||
| "lint": "yarn check:eslint && yarn check:prettier", | ||||||
| "check:eslint": "eslint src/*", | ||||||
| "check:prettier": "prettier --check .", | ||||||
|
|
@@ -24,6 +25,7 @@ | |||||
| "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "1.3.0", | ||||||
| "@atlaskit/pragmatic-drag-and-drop-hitbox": "1.0.3", | ||||||
| "@fontsource/inter": "4.5.14", | ||||||
| "@matrix-org/react-sdk-module-api": "2.5.0", | ||||||
| "@tanstack/react-query": "5.24.1", | ||||||
| "@tanstack/react-query-devtools": "5.24.1", | ||||||
| "@tanstack/react-virtual": "3.2.0", | ||||||
|
|
@@ -57,6 +59,7 @@ | |||||
| "jotai": "2.6.0", | ||||||
| "linkify-react": "4.1.3", | ||||||
| "linkifyjs": "4.1.3", | ||||||
| "matrix-widget-api": "1.11.0", | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| "matrix-js-sdk": "37.5.0", | ||||||
| "millify": "6.1.0", | ||||||
| "pdfjs-dist": "4.2.67", | ||||||
|
|
@@ -83,6 +86,7 @@ | |||||
| "ua-parser-js": "1.0.35" | ||||||
| }, | ||||||
| "devDependencies": { | ||||||
| "@element-hq/element-call-embedded": "0.12.2", | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you bump the element call version you will need to change replacing and adding |
||||||
| "@esbuild-plugins/node-globals-polyfill": "0.2.3", | ||||||
| "@rollup/plugin-inject": "5.0.3", | ||||||
| "@rollup/plugin-wasm": "6.1.1", | ||||||
|
|
@@ -115,4 +119,5 @@ | |||||
| "vite-plugin-static-copy": "1.0.4", | ||||||
| "vite-plugin-top-level-await": "1.4.4" | ||||||
| } | ||||||
|
|
||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| import { Room } from 'matrix-js-sdk'; | ||
| import React, { useContext, useMemo, useCallback, useEffect, useRef } from 'react'; | ||
| import { Box } from 'folds'; | ||
| import { useCallState } from '../../pages/client/call/CallProvider'; | ||
| import { | ||
| PrimaryRefContext, | ||
| BackupRefContext, | ||
| } from '../../pages/client/call/PersistentCallContainer'; | ||
| import { ScreenSize, useScreenSizeContext } from '../../hooks/useScreenSize'; | ||
| import { useDebounce } from '../../hooks/useDebounce'; | ||
|
|
||
| type OriginalStyles = { | ||
| position?: string; | ||
| top?: string; | ||
| left?: string; | ||
| width?: string; | ||
| height?: string; | ||
| zIndex?: string; | ||
| display?: string; | ||
| visibility?: string; | ||
| pointerEvents?: string; | ||
| border?: string; | ||
| }; | ||
|
|
||
| export function CallView({ room }: { room: Room }) { | ||
| const primaryIframeRef = useContext(PrimaryRefContext); | ||
| const backupIframeRef = useContext(BackupRefContext); | ||
| const iframeHostRef = useRef<HTMLDivElement>(null); | ||
|
|
||
| const originalIframeStylesRef = useRef<OriginalStyles | null>(null); | ||
| const { activeCallRoomId, isPrimaryIframe, isChatOpen } = useCallState(); | ||
| const isViewingActiveCall = useMemo( | ||
| () => activeCallRoomId !== null && activeCallRoomId === room.roomId, | ||
| [activeCallRoomId, room.roomId] | ||
| ); | ||
|
|
||
| const screenSize = useScreenSizeContext(); | ||
| /* eslint-disable-next-line no-nested-ternary */ | ||
| const activeIframeDisplayRef = isPrimaryIframe | ||
| ? isViewingActiveCall | ||
| ? primaryIframeRef | ||
| : backupIframeRef | ||
| : isViewingActiveCall | ||
| ? backupIframeRef | ||
| : primaryIframeRef; | ||
|
|
||
| const applyFixedPositioningToIframe = useCallback(() => { | ||
| const iframeElement = activeIframeDisplayRef?.current; | ||
| const hostElement = iframeHostRef?.current; | ||
|
|
||
| if (iframeElement && hostElement) { | ||
| if (!originalIframeStylesRef.current) { | ||
| const computed = window.getComputedStyle(iframeElement); | ||
| originalIframeStylesRef.current = { | ||
| position: iframeElement.style.position || computed.position, | ||
| top: iframeElement.style.top || computed.top, | ||
| left: iframeElement.style.left || computed.left, | ||
| width: iframeElement.style.width || computed.width, | ||
| height: iframeElement.style.height || computed.height, | ||
| zIndex: iframeElement.style.zIndex || computed.zIndex, | ||
| display: iframeElement.style.display || computed.display, | ||
| visibility: iframeElement.style.visibility || computed.visibility, | ||
| pointerEvents: iframeElement.style.pointerEvents || computed.pointerEvents, | ||
| border: iframeElement.style.border || computed.border, | ||
| }; | ||
| } | ||
|
|
||
| const hostRect = hostElement.getBoundingClientRect(); | ||
|
|
||
| iframeElement.style.position = 'fixed'; | ||
| iframeElement.style.top = `${hostRect.top}px`; | ||
| iframeElement.style.left = `${hostRect.left}px`; | ||
| iframeElement.style.width = `${hostRect.width}px`; | ||
| iframeElement.style.height = `${hostRect.height}px`; | ||
| iframeElement.style.border = 'none'; | ||
| iframeElement.style.zIndex = '1000'; | ||
| iframeElement.style.display = room.isCallRoom() ? 'block' : 'none'; | ||
| iframeElement.style.visibility = 'visible'; | ||
| iframeElement.style.pointerEvents = 'auto'; | ||
| } | ||
| }, [activeIframeDisplayRef, room]); | ||
|
|
||
| const debouncedApplyFixedPositioning = useDebounce(applyFixedPositioningToIframe, { | ||
| wait: 50, | ||
| immediate: false, | ||
| }); | ||
| useEffect(() => { | ||
| const iframeElement = activeIframeDisplayRef?.current; | ||
| const hostElement = iframeHostRef?.current; | ||
|
|
||
| if (room.isCallRoom() || (isViewingActiveCall && iframeElement && hostElement)) { | ||
| applyFixedPositioningToIframe(); | ||
|
|
||
| const resizeObserver = new ResizeObserver(debouncedApplyFixedPositioning); | ||
| if (hostElement) resizeObserver.observe(hostElement); | ||
| window.addEventListener('scroll', debouncedApplyFixedPositioning, true); | ||
|
|
||
| return () => { | ||
| resizeObserver.disconnect(); | ||
| window.removeEventListener('scroll', debouncedApplyFixedPositioning, true); | ||
|
|
||
| if (iframeElement && originalIframeStylesRef.current) { | ||
| const originalStyles = originalIframeStylesRef.current; | ||
| (Object.keys(originalStyles) as Array<keyof OriginalStyles>).forEach((key) => { | ||
| if (key in iframeElement.style) { | ||
| iframeElement.style[key as any] = originalStyles[key] || ''; | ||
| } | ||
| }); | ||
| } | ||
| originalIframeStylesRef.current = null; | ||
| }; | ||
| } | ||
|
|
||
| return undefined; | ||
| }, [ | ||
| activeIframeDisplayRef, | ||
| applyFixedPositioningToIframe, | ||
| debouncedApplyFixedPositioning, | ||
| isPrimaryIframe, | ||
| isViewingActiveCall, | ||
| room, | ||
| ]); | ||
|
|
||
| const isCallViewVisible = room.isCallRoom() && (screenSize === ScreenSize.Desktop || !isChatOpen); | ||
|
|
||
| return ( | ||
| <Box grow="Yes" direction="Column" style={{ display: isCallViewVisible ? 'flex' : 'none' }}> | ||
| <div | ||
| ref={iframeHostRef} | ||
| style={{ | ||
| width: '100%', | ||
| height: '100%', | ||
| position: 'relative', | ||
| pointerEvents: 'none', | ||
| display: 'flex', | ||
| }} | ||
| /> | ||
| </Box> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { Widget } from 'matrix-widget-api'; | ||
| import { IApp } from './SmallWidget'; | ||
|
|
||
| // Wrapper class for the widget definition | ||
| export class CinnyWidget extends Widget { | ||
| public constructor(private rawDefinition: IApp) { | ||
| super(rawDefinition); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This module does not exists anymore ...
https://github.com/matrix-org/matrix-react-sdk-module-api?tab=readme-ov-file#deprecation-