Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat(whiteboard) add native implementation (#14327)
Mihaela Dumitru3f657c3ded19
diff --git a/css/main.scss b/css/main.scssindex b6c4efbdfb..8d85d145f9 100644--- a/css/main.scss+++ b/css/main.scss@@ -36,6 +36,7 @@ $flagsImagePath: "../images/";@import 'modals/invite/info';@import 'modals/screen-share/share-audio';@import 'modals/screen-share/share-screen-warning';+@import 'modals/whiteboard';@import 'videolayout_default';@import 'subject';@import 'popup_menu';diff --git a/css/modals/_whiteboard.scss b/css/modals/_whiteboard.scssnew file mode 100644index 0000000000..5a133e66e7--- /dev/null+++ b/css/modals/_whiteboard.scss@@ -0,0 +1,7 @@+.whiteboard {++ .excalidraw-wrapper {+ height: 100vh;+ width: 100vw;+ }+}diff --git a/globals.d.ts b/globals.d.tsindex eda5cbea1b..ba59a3fbbd 100644--- a/globals.d.ts+++ b/globals.d.ts@@ -21,6 +21,7 @@ declare global {JitsiMeetElectron?: any;PressureObserver?: any;PressureRecord?: any;+ ReactNativeWebView?: any;// selenium tests handler_sharedVideoPlayer: any;alwaysOnTop: { api: any };diff --git a/globals.native.d.ts b/globals.native.d.tsindex e465b77fff..23e0e3e924 100644--- a/globals.native.d.ts+++ b/globals.native.d.ts@@ -19,6 +19,9 @@ interface IWindow {location: ILocation;PressureObserver?: any;PressureRecord?: any;+ ReactNativeWebView?: any;+ TextDecoder?: any;+ TextEncoder?: any;self: any;top: any;diff --git a/lang/main.json b/lang/main.jsonindex 0e3ae1271a..d7ffbb439c 100644--- a/lang/main.json+++ b/lang/main.json@@ -560,6 +560,7 @@"noNumbers": "No dial-in numbers.","noPassword": "None","noRoom": "No room was specified to dial-in into.",+ "noWhiteboard": "Could not load the whiteboard.","numbers": "Dial-in Numbers","password": "$t(lockRoomPasswordUppercase): ","reachedLimit": "You have reached the limit of your plan.",@@ -567,7 +568,8 @@"sipAudioOnly": "SIP audio only address","title": "Share","tooltip": "Share link and dial-in info for this meeting",- "upgradeOptions": "Please check the upgrade options on"+ "upgradeOptions": "Please check the upgrade options on",+ "whiteboardError": "Error loading the whiteboard. Please try again later."},"inlineDialogFailure": {"msg": "We stumbled a bit.",@@ -1530,6 +1532,7 @@"whiteboard": {"accessibilityLabel": {"heading": "Whiteboard"- }+ },+ "screenTitle": "Whiteboard"}}diff --git a/modules/API/API.js b/modules/API/API.jsindex c784369fff..d7e1d64d0d 100644--- a/modules/API/API.js+++ b/modules/API/API.js@@ -113,7 +113,7 @@ import { isAudioMuteButtonDisabled } from '../../react/features/toolbox/functionimport { setTileView, toggleTileView } from '../../react/features/video-layout/actions.any';import { muteAllParticipants } from '../../react/features/video-menu/actions';import { setVideoQuality } from '../../react/features/video-quality/actions';-import { toggleWhiteboard } from '../../react/features/whiteboard/actions.any';+import { toggleWhiteboard } from '../../react/features/whiteboard/actions.web';import { getJitsiMeetTransport } from '../transport';import {diff --git a/package-lock.json b/package-lock.jsonindex e8b6d5d297..41db1bda62 100644--- a/package-lock.json+++ b/package-lock.json@@ -110,6 +110,7 @@"redux-thunk": "2.4.1","seamless-scroll-polyfill": "2.1.8","semver": "7.5.4",+ "text-encoding": "0.7.0","tss-react": "4.4.4","util": "0.12.1","uuid": "8.3.2",@@ -18625,6 +18626,12 @@"node": ">=0.10.0"}},+ "node_modules/text-encoding": {+ "version": "0.7.0",+ "resolved": "https://registry.npmjs.org/text-encoding/-/text-encoding-0.7.0.tgz",+ "integrity": "sha512-oJQ3f1hrOnbRLOcwKz0Liq2IcrvDeZRHXhd9RgLrsT+DjWY/nty1Hi7v3dtkaEYbPYe0mUoOfzRrMwfXXwgPUA==",+ "deprecated": "no longer maintained"+ },"node_modules/text-table": {"version": "0.2.0","resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",@@ -33629,6 +33636,11 @@}}},+ "text-encoding": {+ "version": "0.7.0",+ "resolved": "https://registry.npmjs.org/text-encoding/-/text-encoding-0.7.0.tgz",+ "integrity": "sha512-oJQ3f1hrOnbRLOcwKz0Liq2IcrvDeZRHXhd9RgLrsT+DjWY/nty1Hi7v3dtkaEYbPYe0mUoOfzRrMwfXXwgPUA=="+ },"text-table": {"version": "0.2.0","resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",diff --git a/package.json b/package.jsonindex 437001a324..f6e8393821 100644--- a/package.json+++ b/package.json@@ -116,6 +116,7 @@"redux-thunk": "2.4.1","seamless-scroll-polyfill": "2.1.8","semver": "7.5.4",+ "text-encoding": "0.7.0","tss-react": "4.4.4","util": "0.12.1","uuid": "8.3.2",diff --git a/react/features/app/middlewares.any.ts b/react/features/app/middlewares.any.tsindex bcb464c9e3..d56d54c3ff 100644--- a/react/features/app/middlewares.any.ts+++ b/react/features/app/middlewares.any.ts@@ -51,5 +51,6 @@ import '../video-layout/middleware';import '../video-quality/middleware';import '../videosipgw/middleware';import '../visitors/middleware';+import '../whiteboard/middleware.any';import './middleware';diff --git a/react/features/app/middlewares.native.ts b/react/features/app/middlewares.native.tsindex 4e1aa7e712..c951be56f0 100644--- a/react/features/app/middlewares.native.ts+++ b/react/features/app/middlewares.native.ts@@ -13,5 +13,6 @@ import '../mobile/react-native-sdk/middleware';import '../mobile/watchos/middleware';import '../share-room/middleware';import '../shared-video/middleware';+import '../whiteboard/middleware.native';import './middlewares.any';diff --git a/react/features/app/middlewares.web.ts b/react/features/app/middlewares.web.tsindex 9bfa67fb2b..f77b3150ae 100644--- a/react/features/app/middlewares.web.ts+++ b/react/features/app/middlewares.web.ts@@ -22,6 +22,6 @@ import '../talk-while-muted/middleware';import '../toolbox/middleware';import '../face-landmarks/middleware';import '../gifs/middleware';-import '../whiteboard/middleware';+import '../whiteboard/middleware.web';import './middlewares.any';diff --git a/react/features/app/reducers.any.ts b/react/features/app/reducers.any.tsindex 523dc94e11..3af1e69ae0 100644--- a/react/features/app/reducers.any.ts+++ b/react/features/app/reducers.any.ts@@ -55,3 +55,4 @@ import '../video-layout/reducer';import '../video-quality/reducer';import '../videosipgw/reducer';import '../visitors/reducer';+import '../whiteboard/reducer';diff --git a/react/features/app/reducers.web.ts b/react/features/app/reducers.web.tsindex 071d0534ef..33ccaff673 100644--- a/react/features/app/reducers.web.ts+++ b/react/features/app/reducers.web.ts@@ -16,7 +16,6 @@ import '../noise-suppression/reducer';import '../screenshot-capture/reducer';import '../talk-while-muted/reducer';import '../virtual-background/reducer';-import '../whiteboard/reducer';import '../web-hid/reducer';import './reducers.any';diff --git a/react/features/base/util/httpUtils.ts b/react/features/base/util/httpUtils.tsindex 94b7c176b7..db96caf9fb 100644--- a/react/features/base/util/httpUtils.ts+++ b/react/features/base/util/httpUtils.ts@@ -1,3 +1,5 @@+import base64js from 'base64-js';+import { timeoutPromise } from './timeoutPromise';/**@@ -43,3 +45,37 @@ export function doGetJSON(url: string, retry?: boolean, options?: Object) {return fetchPromise;}++/**+ * Encodes strings to Base64URL.+ *+ * @param {any} data - The byte array to encode.+ * @returns {string}+ */+export const encodeToBase64URL = (data: string): string => base64js+ .fromByteArray(new window.TextEncoder().encode(data))+ .replace(/=/g, '')+ .replace(/\+/g, '-')+ .replace(/\//g, '_');++/**+ * Decodes strings from Base64URL.+ *+ * @param {string} data - The byte array to decode.+ * @returns {string}+ */+export const decodeFromBase64URL = (data: string): string => {+ let s = data;++ // Convert from Base64URL to Base64.+ if (s.length % 4 === 2) {+ s += '==';+ } else if (s.length % 4 === 3) {+ s += '=';+ }++ s = s.replace(/-/g, '+').replace(/_/g, '/');++ // Convert Base64 to a byte array.+ return new window.TextDecoder().decode(base64js.toByteArray(s));+};diff --git a/react/features/etherpad/components/native/SharedDocument.tsx b/react/features/etherpad/components/native/SharedDocument.tsxindex 2e6de89a84..8aa0002229 100644--- a/react/features/etherpad/components/native/SharedDocument.tsx+++ b/react/features/etherpad/components/native/SharedDocument.tsx@@ -56,6 +56,7 @@ class SharedDocument extends PureComponent<IProps> {style = { styles.sharedDocContainer }><WebViewhideKeyboardAccessoryView = { true }+ incognito = { true }renderLoading = { this._renderLoading }source = {{ uri: _documentUrl ?? '' }}startInLoadingState = { true }diff --git a/react/features/invite/components/dial-in-summary/native/DialInSummary.tsx b/react/features/invite/components/dial-in-summary/native/DialInSummary.tsxindex 88563fc392..b3787bc04f 100644--- a/react/features/invite/components/dial-in-summary/native/DialInSummary.tsx+++ b/react/features/invite/components/dial-in-summary/native/DialInSummary.tsx@@ -76,6 +76,7 @@ class DialInSummary extends PureComponent<IProps> {<JitsiScreenstyle = { styles.backDrop }><WebView+ incognito = { true }onError = { this._onError }onShouldStartLoadWithRequest = { this._onNavigate }renderLoading = { this._renderLoading }diff --git a/react/features/mobile/navigation/components/RootNavigationContainer.tsx b/react/features/mobile/navigation/components/RootNavigationContainer.tsxindex 47e8b76192..77c32ed71d 100644--- a/react/features/mobile/navigation/components/RootNavigationContainer.tsx+++ b/react/features/mobile/navigation/components/RootNavigationContainer.tsx@@ -13,6 +13,7 @@ import { isUnsafeRoomWarningEnabled } from '../../../prejoin/functions';// @ts-ignoreimport WelcomePage from '../../../welcome/components/WelcomePage';import { isWelcomePageEnabled } from '../../../welcome/functions';+import Whiteboard from '../../../whiteboard/components/native/Whiteboard';import { _ROOT_NAVIGATION_READY } from '../actionTypes';import { rootNavigationRef } from '../rootNavigationContainerRef';import { screen } from '../routes';@@ -23,7 +24,8 @@ import {navigationContainerTheme,preJoinScreenOptions,unsafeMeetingScreenOptions,- welcomeScreenOptions+ welcomeScreenOptions,+ whiteboardScreenOptions} from '../screenOptions';import ConnectingPage from './ConnectingPage';@@ -94,6 +96,10 @@ const RootNavigationContainer = ({ dispatch, isUnsafeRoomWarningAvailable, isWelcomponent = { ConnectingPage }name = { screen.connecting }options = { connectingScreenOptions } />+ <RootStack.Screen // @ts-ignore+ component = { Whiteboard }+ name = { screen.conference.whiteboard }+ options = { whiteboardScreenOptions } /><RootStack.Screencomponent = { Prejoin }name = { screen.preJoin }diff --git a/react/features/mobile/navigation/routes.ts b/react/features/mobile/navigation/routes.tsindex 62315e4cfa..c2fb4b0892 100644--- a/react/features/mobile/navigation/routes.ts+++ b/react/features/mobile/navigation/routes.ts@@ -22,7 +22,8 @@ export const screen = {security: 'Security Options',sharedDocument: 'Shared document',speakerStats: 'Speaker Stats',- subtitles: 'Subtitles'+ subtitles: 'Subtitles',+ whiteboard: 'Whiteboard'},connecting: 'Connecting',dialInSummary: 'Dial-In Info',diff --git a/react/features/mobile/navigation/screenOptions.ts b/react/features/mobile/navigation/screenOptions.tsindex 9bc9941dc2..c013d11b16 100644--- a/react/features/mobile/navigation/screenOptions.ts+++ b/react/features/mobile/navigation/screenOptions.ts@@ -188,6 +188,19 @@ export const connectingScreenOptions = {headerShown: false};+/**+ * Screen options for the whiteboard screen.+ */+export const whiteboardScreenOptions = {+ gestureEnabled: true,+ headerStyle: {+ backgroundColor: BaseTheme.palette.ui01+ },+ headerTitleStyle: {+ color: BaseTheme.palette.text01+ }+};+/*** Screen options for pre-join screen.*/diff --git a/react/features/mobile/polyfills/browser.js b/react/features/mobile/polyfills/browser.jsindex 206f57f990..f67613fed7 100644--- a/react/features/mobile/polyfills/browser.js+++ b/react/features/mobile/polyfills/browser.js@@ -1,6 +1,7 @@import { DOMParser } from '@xmldom/xmldom';import { Platform } from 'react-native';import BackgroundTimer from 'react-native-background-timer';+import { TextDecoder, TextEncoder } from 'text-encoding';import 'promise.allsettled/auto'; // Promise.allSettled.import 'react-native-url-polyfill/auto'; // Complete URL polyfill.@@ -313,4 +314,7 @@ function _visitNode(node, callback) {global.sessionStorage = new Storage();}+ global.TextDecoder = TextDecoder;+ global.TextEncoder = TextEncoder;+})(global || window || this); // eslint-disable-line no-invalid-thisdiff --git a/react/features/toolbox/components/native/OverflowMenu.tsx b/react/features/toolbox/components/native/OverflowMenu.tsxindex 7b07d5ee37..9e607f1f72 100644--- a/react/features/toolbox/components/native/OverflowMenu.tsx+++ b/react/features/toolbox/components/native/OverflowMenu.tsx@@ -23,6 +23,7 @@ import { isSpeakerStatsDisabled } from '../../../speaker-stats/functions';import ClosedCaptionButton from '../../../subtitles/components/native/ClosedCaptionButton';import TileViewButton from '../../../video-layout/components/TileViewButton';import styles from '../../../video-menu/components/native/styles';+import WhiteboardButton from '../../../whiteboard/components/native/WhiteboardButton';import { getMovableButtons } from '../../functions.native';import AudioOnlyButton from './AudioOnlyButton';@@ -156,6 +157,7 @@ class OverflowMenu extends PureComponent<IProps, IState> {<RecordButton { ...buttonProps } /><LiveStreamButton { ...buttonProps } /><LinkToSalesforceButton { ...buttonProps } />+ <WhiteboardButton { ...buttonProps } />{/* @ts-ignore */}<Divider style = { styles.divider as ViewStyle } /><SharedVideoButton { ...buttonProps } />diff --git a/react/features/whiteboard/actions.any.ts b/react/features/whiteboard/actions.any.tsindex 7f7f1c490b..0aa86f30c0 100644--- a/react/features/whiteboard/actions.any.ts+++ b/react/features/whiteboard/actions.any.ts@@ -1,31 +1,68 @@import { IStore } from '../app/types';+import { showWarningNotification } from '../notifications/actions';+import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';-import { setWhiteboardOpen } from './actions';-import { isWhiteboardAllowed, isWhiteboardOpen, isWhiteboardVisible } from './functions';-import { WhiteboardStatus } from './types';+import {+ RESET_WHITEBOARD,+ SETUP_WHITEBOARD,+ SET_WHITEBOARD_OPEN+} from './actionTypes';+import { IWhiteboardAction } from './reducer';+/**+ * Configures the whiteboard collaboration details.+ *+ * @param {Object} payload - The whiteboard settings.+ * @returns {{+ * type: SETUP_WHITEBOARD,+ * collabDetails: { roomId: string, roomKey: string }+ * }}+ */+export const setupWhiteboard = ({ collabDetails }: {+ collabDetails: { roomId: string; roomKey: string; };+}): IWhiteboardAction => {+ return {+ type: SETUP_WHITEBOARD,+ collabDetails+ };+};/**- * API to toggle the whiteboard.+ * Cleans up the whiteboard collaboration settings.+ * To be used only on native for cleanup in between conferences.*- * @returns {Function}+ * @returns {{+ * type: RESET_WHITEBOARD+ * }}*/-export function toggleWhiteboard() {- return async (dispatch: IStore['dispatch'], getState: IStore['getState']) => {- const state = getState();- const isAllowed = isWhiteboardAllowed(state);- const isOpen = isWhiteboardOpen(state);+export const resetWhiteboard = (): IWhiteboardAction => {+ return { type: RESET_WHITEBOARD };+};- if (isAllowed) {- if (isOpen && !isWhiteboardVisible(state)) {- dispatch(setWhiteboardOpen(true));- } else if (isOpen && isWhiteboardVisible(state)) {- dispatch(setWhiteboardOpen(false));- } else if (!isOpen) {- dispatch(setWhiteboardOpen(true));- }- } else if (typeof APP !== 'undefined') {- APP.API.notifyWhiteboardStatusChanged(WhiteboardStatus.FORBIDDEN);- }+/**+ * Sets the whiteboard visibility status.+ *+ * @param {boolean} isOpen - The whiteboard visibility flag.+ * @returns {{+ * type: SET_WHITEBOARD_OPEN,+ * isOpen+ * }}+ */+export const setWhiteboardOpen = (isOpen: boolean): IWhiteboardAction => {+ return {+ type: SET_WHITEBOARD_OPEN,+ isOpen};-}+};++/**+ * Shows a warning notification about the whiteboard user limit.+ *+ * @returns {Function}+ */+export const notifyWhiteboardLimit = () => (dispatch: IStore['dispatch']) => {+ dispatch(showWarningNotification({+ titleKey: 'notify.whiteboardLimitTitle',+ descriptionKey: 'notify.whiteboardLimitDescription'+ }, NOTIFICATION_TIMEOUT_TYPE.LONG));+};diff --git a/react/features/whiteboard/actions.native.ts b/react/features/whiteboard/actions.native.tsnew file mode 100644index 0000000000..b0f248015b--- /dev/null+++ b/react/features/whiteboard/actions.native.ts@@ -0,0 +1,23 @@+import { createRestrictWhiteboardEvent } from '../analytics/AnalyticsEvents';+import { sendAnalytics } from '../analytics/functions';+import { IStore } from '../app/types';+import { navigateRoot } from '../mobile/navigation/rootNavigationContainerRef';+import { screen } from '../mobile/navigation/routes';++import { resetWhiteboard } from './actions.any';++export * from './actions.any';++/**+ * Restricts the whiteboard usage.+ *+ * @param {boolean} shouldCloseWhiteboard - Whether to dismiss the whiteboard.+ * @returns {Function}+ */+export const restrictWhiteboard = (shouldCloseWhiteboard = true) => (dispatch: IStore['dispatch']) => {+ if (shouldCloseWhiteboard) {+ navigateRoot(screen.conference.root);+ }+ dispatch(resetWhiteboard());+ sendAnalytics(createRestrictWhiteboardEvent());+};diff --git a/react/features/whiteboard/actions.ts b/react/features/whiteboard/actions.tsdeleted file mode 100644index 912ab2f526..0000000000--- a/react/features/whiteboard/actions.ts+++ /dev/null@@ -1,82 +0,0 @@-import { createRestrictWhiteboardEvent } from '../analytics/AnalyticsEvents';-import { sendAnalytics } from '../analytics/functions';-import { IStore } from '../app/types';-import { showWarningNotification } from '../notifications/actions';-import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';--import {- RESET_WHITEBOARD,- SETUP_WHITEBOARD,- SET_WHITEBOARD_OPEN-} from './actionTypes';-import { IWhiteboardAction } from './reducer';--/**- * Configures the whiteboard collaboration details.- *- * @param {Object} payload - The whiteboard settings.- * @returns {{- * type: SETUP_WHITEBOARD,- * collabDetails: { roomId: string, roomKey: string }- * }}- */-export const setupWhiteboard = ({ collabDetails }: {- collabDetails: { roomId: string; roomKey: string; };-}): IWhiteboardAction => {- return {- type: SETUP_WHITEBOARD,- collabDetails- };-};--/**- * Cleans up the whiteboard collaboration settings.- * To be used only on native for cleanup in between conferences.- *- * @returns {{- * type: RESET_WHITEBOARD- * }}- */-export const resetWhiteboard = (): IWhiteboardAction => {- return { type: RESET_WHITEBOARD };-};--/**- * Sets the whiteboard visibility status.- *- * @param {boolean} isOpen - The whiteboard visibility flag.- * @returns {{- * type: SET_WHITEBOARD_OPEN,- * isOpen- * }}- */-export const setWhiteboardOpen = (isOpen: boolean): IWhiteboardAction => {- return {- type: SET_WHITEBOARD_OPEN,- isOpen- };-};--/**- * Shows a warning notification about the whiteboard user limit.- *- * @returns {Function}- */-export const notifyWhiteboardLimit = () => (dispatch: IStore['dispatch']) => {- dispatch(showWarningNotification({- titleKey: 'notify.whiteboardLimitTitle',- descriptionKey: 'notify.whiteboardLimitDescription'- }, NOTIFICATION_TIMEOUT_TYPE.LONG));-};--/**- * Restricts the whiteboard usage.- *- * @param {boolean} shouldCloseWhiteboard - Whether to dismiss the whiteboard participant.- * @returns {Function}- */-export const restrictWhiteboard = (shouldCloseWhiteboard = true) => (dispatch: IStore['dispatch']) => {- shouldCloseWhiteboard && dispatch(setWhiteboardOpen(false));- dispatch(resetWhiteboard());- sendAnalytics(createRestrictWhiteboardEvent());-};diff --git a/react/features/whiteboard/actions.web.ts b/react/features/whiteboard/actions.web.tsnew file mode 100644index 0000000000..8e67edd463--- /dev/null+++ b/react/features/whiteboard/actions.web.ts@@ -0,0 +1,48 @@+import { createRestrictWhiteboardEvent } from '../analytics/AnalyticsEvents';+import { sendAnalytics } from '../analytics/functions';+import { IStore } from '../app/types';++import { resetWhiteboard, setWhiteboardOpen } from './actions.any';+import { isWhiteboardAllowed, isWhiteboardOpen, isWhiteboardVisible } from './functions';+import { WhiteboardStatus } from './types';++export * from './actions.any';++/**+ * API to toggle the whiteboard.+ *+ * @returns {Function}+ */+export function toggleWhiteboard() {+ return async (dispatch: IStore['dispatch'], getState: IStore['getState']) => {+ const state = getState();+ const isAllowed = isWhiteboardAllowed(state);+ const isOpen = isWhiteboardOpen(state);++ if (isAllowed) {+ if (isOpen && !isWhiteboardVisible(state)) {+ dispatch(setWhiteboardOpen(true));+ } else if (isOpen && isWhiteboardVisible(state)) {+ dispatch(setWhiteboardOpen(false));+ } else if (!isOpen) {+ dispatch(setWhiteboardOpen(true));+ }+ } else if (typeof APP !== 'undefined') {+ APP.API.notifyWhiteboardStatusChanged(WhiteboardStatus.FORBIDDEN);+ }+ };+}++/**+ * Restricts the whiteboard usage.+ *+ * @param {boolean} shouldCloseWhiteboard - Whether to dismiss the whiteboard.+ * @returns {Function}+ */+export const restrictWhiteboard = (shouldCloseWhiteboard = true) => (dispatch: IStore['dispatch']) => {+ if (shouldCloseWhiteboard) {+ dispatch(setWhiteboardOpen(false));+ }+ dispatch(resetWhiteboard());+ sendAnalytics(createRestrictWhiteboardEvent());+};diff --git a/react/features/whiteboard/components/native/Whiteboard.tsx b/react/features/whiteboard/components/native/Whiteboard.tsxnew file mode 100644index 0000000000..7b6bc65520--- /dev/null+++ b/react/features/whiteboard/components/native/Whiteboard.tsx@@ -0,0 +1,220 @@+import { Route } from '@react-navigation/native';+import React, { PureComponent } from 'react';+import { WithTranslation } from 'react-i18next';+import { View, ViewStyle } from 'react-native';+import { WebView } from 'react-native-webview';+import { connect } from 'react-redux';++import { IReduxState, IStore } from '../../../app/types';+import { getCurrentConference } from '../../../base/conference/functions';+import { IJitsiConference } from '../../../base/conference/reducer';+import { openDialog } from '../../../base/dialog/actions';+import { translate } from '../../../base/i18n/functions';+import JitsiScreen from '../../../base/modal/components/JitsiScreen';+import LoadingIndicator from '../../../base/react/components/native/LoadingIndicator';+import { safeDecodeURIComponent } from '../../../base/util/uri';+import { setupWhiteboard } from '../../actions.any';+import { WHITEBOARD_ID } from '../../constants';+import { getCollabServerUrl, getWhiteboardInfoForURIString } from '../../functions';++import WhiteboardErrorDialog from './WhiteboardErrorDialog';+import styles, { INDICATOR_COLOR } from './styles';++interface IProps extends WithTranslation {++ /**+ * The whiteboard collab server url.+ */+ collabServerUrl?: string;++ /**+ * The current Jitsi conference.+ */+ conference?: IJitsiConference;++ /**+ * Redux store dispatch method.+ */+ dispatch: IStore['dispatch'];++ /**+ * Window location href.+ */+ locationHref: string;++ /**+ * Default prop for navigating between screen components(React Navigation).+ */+ navigation: any;++ /**+ * Default prop for navigating between screen components(React Navigation).+ */+ route: Route<'', {+ collabDetails: { roomId: string; roomKey: string; };+ collabServerUrl: string;+ localParticipantName: string;+ }>;+}++/**+ * Implements a React native component that displays the whiteboard page for a specific room.+ */+class Whiteboard extends PureComponent<IProps> {++ /**+ * Initializes a new instance.+ *+ * @inheritdoc+ */+ constructor(props: IProps) {+ super(props);++ this._onError = this._onError.bind(this);+ this._onNavigate = this._onNavigate.bind(this);+ this._onMessage = this._onMessage.bind(this);+ this._renderLoading = this._renderLoading.bind(this);+ }++ /**+ * Implements React's {@link Component#componentDidMount()}. Invoked+ * immediately after mounting occurs.+ *+ * @inheritdoc+ * @returns {void}+ */+ componentDidMount() {+ const { navigation, t } = this.props;++ navigation.setOptions({+ headerTitle: t('whiteboard.screenTitle')+ });+ }++ /**+ * Implements React's {@link Component#render()}.+ *+ * @inheritdoc+ */+ render() {+ const { locationHref, route } = this.props;+ const collabServerUrl = safeDecodeURIComponent(route.params?.collabServerUrl);+ const localParticipantName = safeDecodeURIComponent(route.params?.localParticipantName);+ const collabDetails = route.params?.collabDetails;+ const uri = getWhiteboardInfoForURIString(+ locationHref,+ collabServerUrl,+ collabDetails,+ localParticipantName+ ) ?? '';++ return (+ <JitsiScreen+ safeAreaInsets = { [ 'bottom', 'left', 'right' ] }+ style = { styles.backDrop }>+ <WebView+ incognito = { true }+ javaScriptEnabled = { true }+ nestedScrollEnabled = { true }+ onError = { this._onError }+ onMessage = { this._onMessage }+ onShouldStartLoadWithRequest = { this._onNavigate }+ renderLoading = { this._renderLoading }+ scrollEnabled = { true }+ setSupportMultipleWindows = { false }+ source = {{ uri }}+ startInLoadingState = { true }+ style = { styles.webView } />+ </JitsiScreen>+ );+ }++ /**+ * Callback to handle the error if the page fails to load.+ *+ * @returns {void}+ */+ _onError() {+ this.props.dispatch(openDialog(WhiteboardErrorDialog));+ }++ /**+ * Callback to intercept navigation inside the webview and make the native app handle the whiteboard requests.+ *+ * NOTE: We don't navigate to anywhere else from that view.+ *+ * @param {any} request - The request object.+ * @returns {boolean}+ */+ _onNavigate(request: { url: string; }) {+ const { url } = request;+ const { locationHref, route } = this.props;+ const collabServerUrl = route.params?.collabServerUrl;+ const collabDetails = route.params?.collabDetails;+ const localParticipantName = route.params?.localParticipantName;++ return url === getWhiteboardInfoForURIString(+ locationHref,+ collabServerUrl,+ collabDetails,+ localParticipantName+ );+ }++ /**+ * Callback to handle the message events.+ *+ * @param {any} event - The event.+ * @returns {void}+ */+ _onMessage(event: any) {+ const { collabServerUrl, conference } = this.props;+ const collabDetails = JSON.parse(event.nativeEvent.data);++ if (collabDetails?.roomId && collabDetails?.roomKey) {+ this.props.dispatch(setupWhiteboard({ collabDetails }));++ // Broadcast the collab details.+ conference?.getMetadataHandler().setMetadata(WHITEBOARD_ID, {+ collabServerUrl,+ collabDetails+ });+ }+ }++ /**+ * Renders the loading indicator.+ *+ * @returns {React$Component<any>}+ */+ _renderLoading() {+ return (+ <View style = { styles.indicatorWrapper as ViewStyle }>+ <LoadingIndicator+ color = { INDICATOR_COLOR }+ size = 'large' />+ </View>+ );+ }+}++/**+ * Maps (parts of) the redux state to the associated+ * {@code WaitForOwnerDialog}'s props.+ *+ * @param {Object} state - The redux state.+ * @private+ * @returns {IProps}+ */+function mapStateToProps(state: IReduxState) {+ const { locationURL } = state['features/base/connection'];+ const { href = '' } = locationURL ?? {};++ return {+ conference: getCurrentConference(state),+ collabServerUrl: getCollabServerUrl(state),+ locationHref: href+ };+}++export default translate(connect(mapStateToProps)(Whiteboard));diff --git a/react/features/whiteboard/components/native/WhiteboardButton.tsx b/react/features/whiteboard/components/native/WhiteboardButton.tsxnew file mode 100644index 0000000000..ce3e80c291--- /dev/null+++ b/react/features/whiteboard/components/native/WhiteboardButton.tsx@@ -0,0 +1,43 @@+import { connect } from 'react-redux';++import { IReduxState } from '../../../app/types';+import { translate } from '../../../base/i18n/functions';+import { IconWhiteboard } from '../../../base/icons/svg';+import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';+import { setWhiteboardOpen } from '../../actions.any';+import { isWhiteboardButtonVisible } from '../../functions';++/**+ * Component that renders a toolbar button for the whiteboard.+ */+class WhiteboardButton extends AbstractButton<AbstractButtonProps> {+ accessibilityLabel = 'toolbar.accessibilityLabel.showWhiteboard';+ icon = IconWhiteboard;+ label = 'toolbar.showWhiteboard';+ tooltip = 'toolbar.showWhiteboard';++ /**+ * Handles clicking / pressing the button, and opens the whiteboard view.+ *+ * @private+ * @returns {void}+ */+ _handleClick() {+ this.props.dispatch(setWhiteboardOpen(true));+ }+}++/**+ * Maps part of the Redux state to the props of this component.+ *+ * @param {Object} state - The Redux state.+ * @private+ * @returns {IProps}+ */+function _mapStateToProps(state: IReduxState) {+ return {+ visible: isWhiteboardButtonVisible(state)+ };+}++export default translate(connect(_mapStateToProps)(WhiteboardButton));diff --git a/react/features/whiteboard/components/native/WhiteboardErrorDialog.tsx b/react/features/whiteboard/components/native/WhiteboardErrorDialog.tsxnew file mode 100644index 0000000000..1b145da0f0--- /dev/null+++ b/react/features/whiteboard/components/native/WhiteboardErrorDialog.tsx@@ -0,0 +1,15 @@+import React from 'react';++import AlertDialog from '../../../base/dialog/components/native/AlertDialog';++/**+ * Dialog to inform the user that we couldn't load the whiteboard.+ *+ * @returns {JSX.Element}+ */+const WhiteboardErrorDialog = () => (+ <AlertDialog+ contentKey = 'info.whiteboardError' />+);++export default WhiteboardErrorDialog;diff --git a/react/features/whiteboard/components/native/WhiteboardLimitDialog.tsx b/react/features/whiteboard/components/native/WhiteboardLimitDialog.tsxnew file mode 100644index 0000000000..03ae5ed7db--- /dev/null+++ b/react/features/whiteboard/components/native/WhiteboardLimitDialog.tsx@@ -0,0 +1,43 @@+import React from 'react';+import { useTranslation } from 'react-i18next';+import { Text, TextStyle } from 'react-native';+import { useSelector } from 'react-redux';++import ConfirmDialog from '../../../base/dialog/components/native/ConfirmDialog';+import Link from '../../../base/react/components/native/Link';+import { getWhiteboardConfig } from '../../functions';++import styles from './styles';++/**+ * Component that renders the whiteboard user limit dialog.+ *+ * @returns {JSX.Element}+ */+const WhiteboardLimitDialog = () => {+ const { t } = useTranslation();+ const { limitUrl } = useSelector(getWhiteboardConfig);++ return (+ <ConfirmDialog+ cancelLabel = { 'dialog.Ok' }+ descriptionKey = { 'dialog.whiteboardLimitContent' }+ isConfirmHidden = { true }+ title = { 'dialog.whiteboardLimitTitle' }>+ {limitUrl && (+ <Text style = { styles.limitUrlText as TextStyle }>+ {` ${t('dialog.whiteboardLimitReference')}+`}+ <Link+ style = { styles.limitUrl }+ url = { limitUrl }>+ {t('dialog.whiteboardLimitReferenceUrl')}+ </Link>+ .+ </Text>+ )}+ </ConfirmDialog>+ );+};++export default WhiteboardLimitDialog;diff --git a/react/features/whiteboard/components/native/styles.ts b/react/features/whiteboard/components/native/styles.tsnew file mode 100644index 0000000000..40a432dae3--- /dev/null+++ b/react/features/whiteboard/components/native/styles.ts@@ -0,0 +1,37 @@+import BaseTheme from '../../../base/ui/components/BaseTheme.native';++export const INDICATOR_COLOR = BaseTheme.palette.ui07;++const WV_BACKGROUND = BaseTheme.palette.ui03;++export default {++ backDrop: {+ backgroundColor: WV_BACKGROUND,+ flex: 1+ },++ indicatorWrapper: {+ alignItems: 'center',+ backgroundColor: BaseTheme.palette.ui10,+ height: '100%',+ justifyContent: 'center'+ },++ webView: {+ backgroundColor: WV_BACKGROUND,+ flex: 1+ },++ limitUrlText: {+ alignItems: 'center',+ display: 'flex',+ marginBottom: BaseTheme.spacing[2],+ textAlign: 'center'+ },++ limitUrl: {+ color: BaseTheme.palette.link01,+ fontWeight: 'bold'+ }+};diff --git a/react/features/whiteboard/components/web/NoWhiteboardError.tsx b/react/features/whiteboard/components/web/NoWhiteboardError.tsxnew file mode 100644index 0000000000..f18e79837a--- /dev/null+++ b/react/features/whiteboard/components/web/NoWhiteboardError.tsx@@ -0,0 +1,25 @@+import React from 'react';+import { useTranslation } from 'react-i18next';++/**+ * The type of the React {@code Component} props of {@link NoWhiteboardError}.+ */+interface IProps {++ /**+ * Additional CSS classnames to append to the root of the component.+ */+ className?: string;+}++const NoWhiteboardError = ({ className }: IProps) => {+ const { t } = useTranslation();++ return (+ <div className = { className } >+ {t('info.noWhiteboard')}+ </div>+ );+};++export default NoWhiteboardError;diff --git a/react/features/whiteboard/components/web/Whiteboard.tsx b/react/features/whiteboard/components/web/Whiteboard.tsxindex 7bcb0eebe8..d8b9a3f48e 100644--- a/react/features/whiteboard/components/web/Whiteboard.tsx+++ b/react/features/whiteboard/components/web/Whiteboard.tsx@@ -1,5 +1,6 @@import { ExcalidrawApp } from '@jitsi/excalidraw';import clsx from 'clsx';+import i18next from 'i18next';import React, { useCallback, useEffect, useRef } from 'react';import { WithTranslation } from 'react-i18next';import { useSelector } from 'react-redux';@@ -143,6 +144,7 @@ const Whiteboard = (props: WithTranslation): JSX.Element => {collabServerUrl = { collabServerUrl }excalidraw = {{isCollaborating: true,+ langCode: i18next.language,// @ts-ignoreref: excalidrawRef,diff --git a/react/features/whiteboard/components/web/WhiteboardApp.tsx b/react/features/whiteboard/components/web/WhiteboardApp.tsxnew file mode 100644index 0000000000..c9bc7daa89--- /dev/null+++ b/react/features/whiteboard/components/web/WhiteboardApp.tsx@@ -0,0 +1,91 @@+import { generateCollaborationLinkData } from '@jitsi/excalidraw';+import React, { ComponentType } from 'react';++import BaseApp from '../../../base/app/components/BaseApp';+import GlobalStyles from '../../../base/ui/components/GlobalStyles.web';+import JitsiThemeProvider from '../../../base/ui/components/JitsiThemeProvider.web';+import { decodeFromBase64URL } from '../../../base/util/httpUtils';+import { parseURLParams } from '../../../base/util/parseURLParams';+import { safeDecodeURIComponent } from '../../../base/util/uri';+import logger from '../../logger';++import NoWhiteboardError from './NoWhiteboardError';+import WhiteboardWrapper from './WhiteboardWrapper';++/**+ * Wrapper application for the whiteboard.+ *+ * @augments BaseApp+ */+export default class WhiteboardApp extends BaseApp<any> {+ /**+ * Navigates to {@link Whiteboard} upon mount.+ *+ * @returns {void}+ */+ async componentDidMount() {+ await super.componentDidMount();++ const { state } = parseURLParams(window.location.href, true);+ const decodedState = JSON.parse(decodeFromBase64URL(state));+ const { collabServerUrl, localParticipantName } = decodedState;+ let { roomId, roomKey } = decodedState;++ if (!roomId && !roomKey) {+ try {+ const collabDetails = await generateCollaborationLinkData();++ roomId = collabDetails.roomId;+ roomKey = collabDetails.roomKey;++ if (window.ReactNativeWebView) {+ setTimeout(() => {+ window.ReactNativeWebView.postMessage(JSON.stringify(collabDetails));+ }, 0);+ }+ } catch (e: any) {+ logger.error('Couldn\'t generate collaboration link data.', e);+ }+ }++ super._navigate({+ component: () => (+ <>{+ roomId && roomKey && collabServerUrl+ ? <WhiteboardWrapper+ className = 'whiteboard'+ collabDetails = {{+ roomId,+ roomKey+ }}+ collabServerUrl = { safeDecodeURIComponent(collabServerUrl) }+ localParticipantName = { localParticipantName } />+ : <NoWhiteboardError className = 'whiteboard' />+ }</>+ ) });+ }++ /**+ * Overrides the parent method to inject {@link AtlasKitThemeProvider} as+ * the top most component.+ *+ * @override+ */+ _createMainElement(component: ComponentType<any>, props: Object) {+ return (+ <JitsiThemeProvider>+ <GlobalStyles />+ {super._createMainElement(component, props)}+ </JitsiThemeProvider>+ );+ }++ /**+ * Renders the platform specific dialog container.+ *+ * @returns {React$Element}+ */+ _renderDialogContainer() {+ return null;+ }+}diff --git a/react/features/whiteboard/components/web/WhiteboardButton.tsx b/react/features/whiteboard/components/web/WhiteboardButton.tsxindex b242db08f1..7ed69537c3 100644--- a/react/features/whiteboard/components/web/WhiteboardButton.tsx+++ b/react/features/whiteboard/components/web/WhiteboardButton.tsx@@ -5,7 +5,7 @@ import { translate } from '../../../base/i18n/functions';import { IconWhiteboard, IconWhiteboardHide } from '../../../base/icons/svg';import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';import { setOverflowMenuVisible } from '../../../toolbox/actions.web';-import { setWhiteboardOpen } from '../../actions';+import { setWhiteboardOpen } from '../../actions.any';import { isWhiteboardButtonVisible, isWhiteboardVisible } from '../../functions';interface IProps extends AbstractButtonProps {diff --git a/react/features/whiteboard/components/web/WhiteboardWrapper.tsx b/react/features/whiteboard/components/web/WhiteboardWrapper.tsxnew file mode 100644index 0000000000..4ba5522b1d--- /dev/null+++ b/react/features/whiteboard/components/web/WhiteboardWrapper.tsx@@ -0,0 +1,70 @@+import { ExcalidrawApp } from '@jitsi/excalidraw';+import i18next from 'i18next';+import React, { useCallback, useRef } from 'react';++import { WHITEBOARD_UI_OPTIONS } from '../../constants';++/**+ * Whiteboard wrapper for mobile.+ *+ * @returns {JSX.Element}+ */+const WhiteboardWrapper = ({+ className,+ collabDetails,+ collabServerUrl,+ localParticipantName+}: {+ className?: string;+ collabDetails: {+ roomId: string;+ roomKey: string;+ };+ collabServerUrl: string;+ localParticipantName: string;+}) => {+ const excalidrawRef = useRef<any>(null);+ const excalidrawAPIRef = useRef<any>(null);+ const collabAPIRef = useRef<any>(null);++ const getExcalidrawAPI = useCallback(excalidrawAPI => {+ if (excalidrawAPIRef.current) {+ return;+ }+ excalidrawAPIRef.current = excalidrawAPI;+ }, []);++ const getCollabAPI = useCallback(collabAPI => {+ if (collabAPIRef.current) {+ return;+ }+ collabAPIRef.current = collabAPI;+ collabAPIRef.current.setUsername(localParticipantName);+ }, [ localParticipantName ]);++ return (+ <div className = { className }>+ <div className = 'excalidraw-wrapper'>+ <ExcalidrawApp+ collabDetails = { collabDetails }+ collabServerUrl = { collabServerUrl }+ detectScroll = { true }+ excalidraw = {{+ isCollaborating: true,+ langCode: i18next.language,++ // @ts-ignore+ ref: excalidrawRef,+ theme: 'light',+ UIOptions: WHITEBOARD_UI_OPTIONS+ }}+ getCollabAPI = { getCollabAPI }+ getExcalidrawAPI = { getExcalidrawAPI } />+ </div>+++ </div>+ );+};++export default WhiteboardWrapper;diff --git a/react/features/whiteboard/constants.ts b/react/features/whiteboard/constants.tsindex 0202c14418..737a5a287f 100644--- a/react/features/whiteboard/constants.ts+++ b/react/features/whiteboard/constants.ts@@ -62,3 +62,10 @@ export const MIN_USER_LIMIT = 10;* Whiteboard soft limit diff.*/export const USER_LIMIT_THRESHOLD = 5;++/**+ * The pathName for the whiteboard page.+ *+ * @type {string}+ */+export const WHITEBOARD_PATH_NAME = 'static/whiteboard.html';diff --git a/react/features/whiteboard/functions.ts b/react/features/whiteboard/functions.tsindex 436c03e8a4..4718c869b5 100644--- a/react/features/whiteboard/functions.ts+++ b/react/features/whiteboard/functions.ts@@ -5,10 +5,11 @@ import { IReduxState } from '../app/types';import { getCurrentConference } from '../base/conference/functions';import { IWhiteboardConfig } from '../base/config/configType';import { getRemoteParticipants, isLocalParticipantModerator } from '../base/participants/functions';-import { appendURLParam } from '../base/util/uri';+import { encodeToBase64URL } from '../base/util/httpUtils';+import { appendURLHashParam, appendURLParam } from '../base/util/uri';import { getCurrentRoomId, isInBreakoutRoom } from '../breakout-rooms/functions';-import { MIN_USER_LIMIT, USER_LIMIT_THRESHOLD, WHITEBOARD_ID } from './constants';+import { MIN_USER_LIMIT, USER_LIMIT_THRESHOLD, WHITEBOARD_ID, WHITEBOARD_PATH_NAME } from './constants';import { IWhiteboardState } from './reducer';const getWhiteboardState = (state: IReduxState): IWhiteboardState => state['features/whiteboard'];@@ -156,3 +157,50 @@ export const shouldNotifyUserLimit = (state: IReduxState): boolean => {return participantCount + USER_LIMIT_THRESHOLD > userLimit;};++/**+ * Generates the URL for the static whiteboard page.+ *+ * @param {string} locationUrl - The window location href.+ * @param {string} collabServerUrl - The whiteboard collaboration server url.+ * @param {Object} collabDetails - The whiteboard collaboration details.+ * @param {string} localParticipantName - The local participant name.+ * @returns {string}+ */+export function getWhiteboardInfoForURIString(+ locationUrl: any,+ collabServerUrl: string,+ collabDetails: { roomId: string; roomKey: string; },+ localParticipantName: string+): string | undefined {+ if (!collabServerUrl || !locationUrl) {+ return undefined;+ }++ let state = {};+ let url = `${locationUrl.substring(0, locationUrl.lastIndexOf('/'))}/${WHITEBOARD_PATH_NAME}`;++ if (collabDetails?.roomId) {+ state = {+ ...state,+ roomId: collabDetails.roomId+ };+ }++ if (collabDetails?.roomKey) {+ state = {+ ...state,+ roomKey: collabDetails.roomKey+ };+ }++ state = {+ ...state,+ collabServerUrl,+ localParticipantName+ };++ url = appendURLHashParam(url, 'state', encodeToBase64URL(JSON.stringify(state)));++ return url;+}diff --git a/react/features/whiteboard/logger.ts b/react/features/whiteboard/logger.tsnew file mode 100644index 0000000000..50a4ba1147--- /dev/null+++ b/react/features/whiteboard/logger.ts@@ -0,0 +1,3 @@+import { getLogger } from '../base/logging/functions';++export default getLogger('features/whiteboard');diff --git a/react/features/whiteboard/middleware.any.ts b/react/features/whiteboard/middleware.any.tsnew file mode 100644index 0000000000..b6d538728c--- /dev/null+++ b/react/features/whiteboard/middleware.any.ts@@ -0,0 +1,89 @@+import { createOpenWhiteboardEvent } from '../analytics/AnalyticsEvents';+import { sendAnalytics } from '../analytics/functions';+import { IStore } from '../app/types';+import { getCurrentConference } from '../base/conference/functions';+import { JitsiConferenceEvents } from '../base/lib-jitsi-meet';+import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';+import StateListenerRegistry from '../base/redux/StateListenerRegistry';++import { SET_WHITEBOARD_OPEN } from './actionTypes';+import {+ notifyWhiteboardLimit,+ resetWhiteboard,+ restrictWhiteboard,+ setWhiteboardOpen,+ setupWhiteboard+} from './actions';+import { WHITEBOARD_ID } from './constants';+import {+ isWhiteboardOpen,+ shouldEnforceUserLimit,+ shouldNotifyUserLimit+} from './functions';++MiddlewareRegistry.register((store: IStore) => next => action => {+ const state = store.getState();++ switch (action.type) {+ case SET_WHITEBOARD_OPEN: {+ const enforceUserLimit = shouldEnforceUserLimit(state);+ const notifyUserLimit = shouldNotifyUserLimit(state);++ if (action.isOpen && !enforceUserLimit && !notifyUserLimit) {+ sendAnalytics(createOpenWhiteboardEvent());++ return next(action);+ }++ break;+ }+ }++ return next(action);+});++/**+ * Set up state change listener to perform maintenance tasks when the conference+ * is left or failed, e.g. Disable the whiteboard if it's left open.+ */+StateListenerRegistry.register(+ state => getCurrentConference(state),+ (conference, { dispatch }, previousConference): void => {+ if (conference !== previousConference) {+ dispatch(resetWhiteboard());+ }+ if (conference && !previousConference) {+ conference.on(JitsiConferenceEvents.METADATA_UPDATED, (metadata: any) => {+ if (metadata[WHITEBOARD_ID]) {+ dispatch(setupWhiteboard({+ collabDetails: metadata[WHITEBOARD_ID].collabDetails+ }));+ dispatch(setWhiteboardOpen(true));+ }+ });+ }+ });++/**+ * Set up state change listener to limit whiteboard access.+ */+StateListenerRegistry.register(+ state => shouldEnforceUserLimit(state),+ (enforceUserLimit, { dispatch, getState }): void => {+ if (isWhiteboardOpen(getState()) && enforceUserLimit) {+ dispatch(restrictWhiteboard());+ }+ }+);++/**+ * Set up state change listener to notify about whiteboard usage.+ */+StateListenerRegistry.register(+ state => shouldNotifyUserLimit(state),+ (notifyUserLimit, { dispatch, getState }, prevNotifyUserLimit): void => {+ if (isWhiteboardOpen(getState()) && notifyUserLimit && !prevNotifyUserLimit) {+ dispatch(notifyWhiteboardLimit());+ }+ }+);diff --git a/react/features/whiteboard/middleware.native.ts b/react/features/whiteboard/middleware.native.tsnew file mode 100644index 0000000000..f2c64f29c9--- /dev/null+++ b/react/features/whiteboard/middleware.native.ts@@ -0,0 +1,80 @@+import { AnyAction } from 'redux';++import { IStore } from '../app/types';+import { hideDialog, openDialog } from '../base/dialog/actions';+import { isDialogOpen } from '../base/dialog/functions';+import { getLocalParticipant } from '../base/participants/functions';+import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';+import { navigateRoot } from '../mobile/navigation/rootNavigationContainerRef';+import { screen } from '../mobile/navigation/routes';++import { SET_WHITEBOARD_OPEN } from './actionTypes';+import {+ notifyWhiteboardLimit,+ restrictWhiteboard+} from './actions';+import WhiteboardLimitDialog from './components/native/WhiteboardLimitDialog';+import {+ getCollabDetails,+ getCollabServerUrl,+ shouldEnforceUserLimit,+ shouldNotifyUserLimit+} from './functions';+import './middleware.any';++/**+ * Middleware which intercepts whiteboard actions to handle changes to the related state.+ *+ * @param {Store} store - The redux store.+ * @returns {Function}+ */+MiddlewareRegistry.register((store: IStore) => (next: Function) => async (action: AnyAction) => {+ const { dispatch, getState } = store;+ const state = getState();++ switch (action.type) {+ case SET_WHITEBOARD_OPEN: {+ const enforceUserLimit = shouldEnforceUserLimit(state);+ const notifyUserLimit = shouldNotifyUserLimit(state);++ if (enforceUserLimit) {+ dispatch(restrictWhiteboard(false));+ dispatch(openDialog(WhiteboardLimitDialog));++ return next(action);+ }++ if (action.isOpen) {+ if (enforceUserLimit) {+ dispatch(restrictWhiteboard());++ return next(action);+ }++ if (notifyUserLimit) {+ dispatch(notifyWhiteboardLimit());+ }++ if (isDialogOpen(state, WhiteboardLimitDialog)) {+ dispatch(hideDialog(WhiteboardLimitDialog));+ }++ const collabDetails = getCollabDetails(state);+ const collabServerUrl = getCollabServerUrl(state);+ const localParticipantName = getLocalParticipant(state)?.name;++ navigateRoot(screen.conference.whiteboard, {+ collabDetails,+ collabServerUrl,+ localParticipantName+ });++ return next(action);+ }++ break;+ }+ }++ return next(action);+});diff --git a/react/features/whiteboard/middleware.ts b/react/features/whiteboard/middleware.web.tssimilarity index 70%rename from react/features/whiteboard/middleware.tsrename to react/features/whiteboard/middleware.web.tsindex ac8be7e2a6..181d627292 100644--- a/react/features/whiteboard/middleware.ts+++ b/react/features/whiteboard/middleware.web.ts@@ -1,17 +1,13 @@import { generateCollaborationLinkData } from '@jitsi/excalidraw';import { AnyAction } from 'redux';-import { createOpenWhiteboardEvent } from '../analytics/AnalyticsEvents';-import { sendAnalytics } from '../analytics/functions';import { IStore } from '../app/types';import { getCurrentConference } from '../base/conference/functions';import { hideDialog, openDialog } from '../base/dialog/actions';import { isDialogOpen } from '../base/dialog/functions';-import { JitsiConferenceEvents } from '../base/lib-jitsi-meet';import { participantJoined, participantLeft, pinParticipant } from '../base/participants/actions';import { FakeParticipant } from '../base/participants/types';import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';-import StateListenerRegistry from '../base/redux/StateListenerRegistry';import { getCurrentRoomId } from '../breakout-rooms/functions';import { addStageParticipant } from '../filmstrip/actions.web';import { isStageFilmstripAvailable } from '../filmstrip/functions.web';@@ -19,9 +15,7 @@ import { isStageFilmstripAvailable } from '../filmstrip/functions.web';import { RESET_WHITEBOARD, SET_WHITEBOARD_OPEN } from './actionTypes';import {notifyWhiteboardLimit,- resetWhiteboard,restrictWhiteboard,- setWhiteboardOpen,setupWhiteboard} from './actions';import WhiteboardLimitDialog from './components/web/WhiteboardLimitDialog';@@ -29,13 +23,14 @@ import { WHITEBOARD_ID, WHITEBOARD_PARTICIPANT_NAME } from './constants';import {getCollabDetails,getCollabServerUrl,- isWhiteboardOpen,isWhiteboardPresent,shouldEnforceUserLimit,shouldNotifyUserLimit} from './functions';import { WhiteboardStatus } from './types';+import './middleware.any';+const focusWhiteboard = (store: IStore) => {const { dispatch, getState } = store;const state = getState();@@ -79,7 +74,7 @@ MiddlewareRegistry.register((store: IStore) => (next: Function) => async (actiondispatch(restrictWhiteboard(false));dispatch(openDialog(WhiteboardLimitDialog));- return;+ return next(action);}if (!existingCollabDetails) {@@ -99,14 +94,14 @@ MiddlewareRegistry.register((store: IStore) => (next: Function) => async (action});raiseWhiteboardNotification(WhiteboardStatus.INSTANTIATED);- return;+ return next(action);}if (action.isOpen) {if (enforceUserLimit) {dispatch(restrictWhiteboard());- return;+ return next(action);}if (notifyUserLimit) {@@ -118,10 +113,9 @@ MiddlewareRegistry.register((store: IStore) => (next: Function) => async (action}focusWhiteboard(store);- sendAnalytics(createOpenWhiteboardEvent());raiseWhiteboardNotification(WhiteboardStatus.SHOWN);- return;+ return next(action);}dispatch(participantLeft(WHITEBOARD_ID, conference, { fakeParticipant: FakeParticipant.Whiteboard }));@@ -152,49 +146,3 @@ function raiseWhiteboardNotification(status: WhiteboardStatus) {}}-/**- * Set up state change listener to perform maintenance tasks when the conference- * is left or failed, e.g. Disable the whiteboard if it's left open.- */-StateListenerRegistry.register(- state => getCurrentConference(state),- (conference, { dispatch }, previousConference): void => {- if (conference !== previousConference) {- dispatch(resetWhiteboard());- }- if (conference && !previousConference) {- conference.on(JitsiConferenceEvents.METADATA_UPDATED, (metadata: any) => {- if (metadata[WHITEBOARD_ID]) {- dispatch(setupWhiteboard({- collabDetails: metadata[WHITEBOARD_ID].collabDetails- }));- dispatch(setWhiteboardOpen(true));- }- });- }- });--/**- * Set up state change listener to limit whiteboard access.- */-StateListenerRegistry.register(- state => shouldEnforceUserLimit(state),- (enforceUserLimit, { dispatch, getState }): void => {- if (isWhiteboardOpen(getState()) && enforceUserLimit) {- dispatch(restrictWhiteboard());- }- }-);--/**- * Set up state change listener to notify about whiteboard usage.- */-StateListenerRegistry.register(- state => shouldNotifyUserLimit(state),- (notifyUserLimit, { dispatch, getState }, prevNotifyUserLimit): void => {- if (isWhiteboardOpen(getState()) && notifyUserLimit && !prevNotifyUserLimit) {- dispatch(notifyWhiteboardLimit());- }- }-);-diff --git a/react/index.web.js b/react/index.web.jsindex d97c6a5d05..301826515d 100644--- a/react/index.web.js+++ b/react/index.web.js@@ -7,6 +7,7 @@ import Platform from './features/base/react/Platform.web';import { getJitsiMeetGlobalNS } from './features/base/util/helpers';import DialInSummaryApp from './features/invite/components/dial-in-summary/web/DialInSummaryApp';import PrejoinApp from './features/prejoin/components/web/PrejoinApp';+import WhiteboardApp from './features/whiteboard/components/web/WhiteboardApp';const logger = getLogger('index.web');@@ -60,7 +61,8 @@ document.addEventListener('DOMContentLoaded', () => {globalNS.entryPoints = {APP: App,PREJOIN: PrejoinApp,- DIALIN: DialInSummaryApp+ DIALIN: DialInSummaryApp,+ WHITEBOARD: WhiteboardApp};globalNS.renderEntryPoint = ({diff --git a/static/whiteboard.html b/static/whiteboard.htmlnew file mode 100644index 0000000000..e86903630a--- /dev/null+++ b/static/whiteboard.html@@ -0,0 +1,33 @@+<html xmlns="http://www.w3.org/1999/html">++<head>+ <meta charset="utf-8">+ <meta http-equiv="content-type" content="text/html;charset=utf-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <!--#include virtual="/base.html" -->+ <link rel="stylesheet" href="css/all.css">+ <script>+ window.EXCALIDRAW_ASSET_PATH = 'libs/';++ document.addEventListener('DOMContentLoaded', async () => {+ if (!JitsiMeetJS.app) {+ return;+ }++ JitsiMeetJS.app.renderEntryPoint({+ Component: JitsiMeetJS.app.entryPoints.WHITEBOARD+ });+ });+ </script>+ <!--#include virtual="/title.html" -->+ <script><!--#include virtual="/config.js" --></script>+ <script><!--#include virtual="/interface_config.js" --></script>+ <script src="libs/lib-jitsi-meet.min.js?v=139"></script>+ <script src="libs/app.bundle.min.js?v=139"></script>+</head>++<body>+ <div id="react" role="main"></div>+</body>++</html>\ No newline at end of file