From 54d0219d34495c41eec3a44b42f47c46eb438880 Mon Sep 17 00:00:00 2001 From: damencho Date: Sun, 22 Dec 2024 17:15:55 -0600 Subject: [PATCH 1/2] fix(shared-video): Gets from info from the incoming presence. Ignore using from field send in attributes of the command. --- react/features/shared-video/middleware.any.ts | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/react/features/shared-video/middleware.any.ts b/react/features/shared-video/middleware.any.ts index 6e1662452b2b..1aa8b27a17d7 100644 --- a/react/features/shared-video/middleware.any.ts +++ b/react/features/shared-video/middleware.any.ts @@ -55,27 +55,41 @@ MiddlewareRegistry.register(store => next => action => { conference.addCommandListener(SHARED_VIDEO, ({ value, attributes }: { attributes: { - from: string; muted: string; state: string; time: string; }; value: string; }) => { + muted: string; state: string; time: string; }; value: string; }, + from: string) => { const state = getState(); - - const { from } = attributes; const sharedVideoStatus = attributes.state; + const { ownerId } = state['features/shared-video']; + + if (ownerId && ownerId !== from) { + logger.warn( + `User with id: ${from} sent shared video command: ${sharedVideoStatus} while we are playing.`); + + return; + } + if (isSharingStatus(sharedVideoStatus)) { // confirmShowVideo is undefined the first time we receive // when confirmShowVideo is false we ignore everything except stop that resets it - if (getState()['features/shared-video'].confirmShowVideo === false) { + if (state['features/shared-video'].confirmShowVideo === false) { return; } - if (isURLAllowedForSharedVideo(value, getState()['features/shared-video'].allowedUrlDomains, true) + if (isURLAllowedForSharedVideo(value, state['features/shared-video'].allowedUrlDomains, true) || localParticipantId === from - || getState()['features/shared-video'].confirmShowVideo) { // if confirmed skip asking again - handleSharingVideoStatus(store, value, attributes, conference); + || state['features/shared-video'].confirmShowVideo) { // if confirmed skip asking again + handleSharingVideoStatus(store, value, { + ...attributes, + from + }, conference); } else { - dispatch(showConfirmPlayingDialog(getParticipantDisplayName(getState(), from), () => { + dispatch(showConfirmPlayingDialog(getParticipantDisplayName(state, from), () => { - handleSharingVideoStatus(store, value, attributes, conference); + handleSharingVideoStatus(store, value, { + ...attributes, + from + }, conference); return true; // on mobile this is used to close the dialog })); @@ -87,11 +101,11 @@ MiddlewareRegistry.register(store => next => action => { if (sharedVideoStatus === 'stop') { const videoParticipant = getParticipantById(state, value); - if (getState()['features/shared-video'].confirmShowVideo === false) { + if (state['features/shared-video'].confirmShowVideo === false) { dispatch(showWarningNotification({ titleKey: 'dialog.shareVideoLinkStopped', titleArguments: { - name: getParticipantDisplayName(getState(), from) + name: getParticipantDisplayName(state, from) } }, NOTIFICATION_TIMEOUT_TYPE.LONG)); } From 1dcb9984cb219a6c2059ef86566353024281e4e8 Mon Sep 17 00:00:00 2001 From: damencho Date: Sun, 22 Dec 2024 17:21:48 -0600 Subject: [PATCH 2/2] fix(shared-video): Remove disable button action from web. --- modules/API/API.js | 2 +- react/features/shared-video/actionTypes.ts | 11 ----- react/features/shared-video/actions.native.ts | 1 - .../{actions.any.ts => actions.ts} | 0 react/features/shared-video/actions.web.ts | 19 --------- .../components/native/AbstractVideoManager.ts | 2 +- .../components/native/SharedVideoButton.ts | 2 +- .../components/web/AbstractVideoManager.ts | 2 +- .../components/web/SharedVideoButton.ts | 15 ++++--- .../shared-video/middleware.native.ts | 1 - .../{middleware.any.ts => middleware.ts} | 2 +- react/features/shared-video/middleware.web.ts | 41 ------------------- react/features/shared-video/reducer.ts | 10 +---- .../web/FakeParticipantContextMenu.tsx | 2 +- 14 files changed, 14 insertions(+), 96 deletions(-) delete mode 100644 react/features/shared-video/actions.native.ts rename react/features/shared-video/{actions.any.ts => actions.ts} (100%) delete mode 100644 react/features/shared-video/actions.web.ts delete mode 100644 react/features/shared-video/middleware.native.ts rename react/features/shared-video/{middleware.any.ts => middleware.ts} (99%) delete mode 100644 react/features/shared-video/middleware.web.ts diff --git a/modules/API/API.js b/modules/API/API.js index 4a5df7963002..c449bce4fe1b 100644 --- a/modules/API/API.js +++ b/modules/API/API.js @@ -115,7 +115,7 @@ import { toggleScreenshotCaptureSummary } from '../../react/features/screenshot- import { isScreenshotCaptureEnabled } from '../../react/features/screenshot-capture/functions'; import SettingsDialog from '../../react/features/settings/components/web/SettingsDialog'; import { SETTINGS_TABS } from '../../react/features/settings/constants'; -import { playSharedVideo, stopSharedVideo } from '../../react/features/shared-video/actions.any'; +import { playSharedVideo, stopSharedVideo } from '../../react/features/shared-video/actions'; import { extractYoutubeIdOrURL } from '../../react/features/shared-video/functions'; import { setRequestingSubtitles, toggleRequestingSubtitles } from '../../react/features/subtitles/actions'; import { isAudioMuteButtonDisabled } from '../../react/features/toolbox/functions'; diff --git a/react/features/shared-video/actionTypes.ts b/react/features/shared-video/actionTypes.ts index 10a981db12e7..defa140b3e74 100644 --- a/react/features/shared-video/actionTypes.ts +++ b/react/features/shared-video/actionTypes.ts @@ -28,17 +28,6 @@ export const RESET_SHARED_VIDEO_STATUS = 'RESET_SHARED_VIDEO_STATUS'; */ export const SET_CONFIRM_SHOW_VIDEO = 'SET_CONFIRM_SHOW_VIDEO'; - -/** - * The type of the action which signals to disable or enable the shared video - * button. - * - * { - * type: SET_DISABLE_BUTTON - * } - */ -export const SET_DISABLE_BUTTON = 'SET_DISABLE_BUTTON'; - /** * The type of the action which sets an array of whitelisted urls. * diff --git a/react/features/shared-video/actions.native.ts b/react/features/shared-video/actions.native.ts deleted file mode 100644 index 02b37d475df7..000000000000 --- a/react/features/shared-video/actions.native.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './actions.any'; diff --git a/react/features/shared-video/actions.any.ts b/react/features/shared-video/actions.ts similarity index 100% rename from react/features/shared-video/actions.any.ts rename to react/features/shared-video/actions.ts diff --git a/react/features/shared-video/actions.web.ts b/react/features/shared-video/actions.web.ts deleted file mode 100644 index 769be0e9f302..000000000000 --- a/react/features/shared-video/actions.web.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { SET_DISABLE_BUTTON } from './actionTypes'; - -export * from './actions.any'; - -/** - * Disabled share video button. - * - * @param {boolean} disabled - The current state of the share video button. - * @returns {{ - * type: SET_DISABLE_BUTTON, - * disabled: boolean - * }} - */ -export function setDisableButton(disabled: boolean) { - return { - type: SET_DISABLE_BUTTON, - disabled - }; -} diff --git a/react/features/shared-video/components/native/AbstractVideoManager.ts b/react/features/shared-video/components/native/AbstractVideoManager.ts index a55cfed7c336..d41c60ba829e 100644 --- a/react/features/shared-video/components/native/AbstractVideoManager.ts +++ b/react/features/shared-video/components/native/AbstractVideoManager.ts @@ -5,7 +5,7 @@ import { IReduxState, IStore } from '../../../app/types'; import { getCurrentConference } from '../../../base/conference/functions'; import { IJitsiConference } from '../../../base/conference/reducer'; import { getLocalParticipant } from '../../../base/participants/functions'; -import { setSharedVideoStatus } from '../../actions.any'; +import { setSharedVideoStatus } from '../../actions'; import { PLAYBACK_STATUSES } from '../../constants'; /** diff --git a/react/features/shared-video/components/native/SharedVideoButton.ts b/react/features/shared-video/components/native/SharedVideoButton.ts index 5fdf41b724da..ca08c90ad75a 100644 --- a/react/features/shared-video/components/native/SharedVideoButton.ts +++ b/react/features/shared-video/components/native/SharedVideoButton.ts @@ -7,7 +7,7 @@ import { translate } from '../../../base/i18n/functions'; import { IconPlay } from '../../../base/icons/svg'; import { getLocalParticipant } from '../../../base/participants/functions'; import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton'; -import { toggleSharedVideo } from '../../actions.native'; +import { toggleSharedVideo } from '../../actions'; import { isSharingStatus } from '../../functions'; /** diff --git a/react/features/shared-video/components/web/AbstractVideoManager.ts b/react/features/shared-video/components/web/AbstractVideoManager.ts index 6f3d3cacb6f0..da157a821e30 100644 --- a/react/features/shared-video/components/web/AbstractVideoManager.ts +++ b/react/features/shared-video/components/web/AbstractVideoManager.ts @@ -15,7 +15,7 @@ import { showWarningNotification } from '../../../notifications/actions'; import { NOTIFICATION_TIMEOUT_TYPE } from '../../../notifications/constants'; import { dockToolbox } from '../../../toolbox/actions'; import { muteLocal } from '../../../video-menu/actions.any'; -import { setSharedVideoStatus, stopSharedVideo } from '../../actions.any'; +import { setSharedVideoStatus, stopSharedVideo } from '../../actions'; import { PLAYBACK_STATUSES } from '../../constants'; const logger = Logger.getLogger(__filename); diff --git a/react/features/shared-video/components/web/SharedVideoButton.ts b/react/features/shared-video/components/web/SharedVideoButton.ts index f1d6240bc750..6cfc9175d562 100644 --- a/react/features/shared-video/components/web/SharedVideoButton.ts +++ b/react/features/shared-video/components/web/SharedVideoButton.ts @@ -3,8 +3,9 @@ import { connect } from 'react-redux'; import { IReduxState } from '../../../app/types'; import { translate } from '../../../base/i18n/functions'; import { IconPlay } from '../../../base/icons/svg'; +import { getLocalParticipant } from '../../../base/participants/functions'; import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton'; -import { toggleSharedVideo } from '../../actions.any'; +import { toggleSharedVideo } from '../../actions'; import { isSharingStatus } from '../../functions'; interface IProps extends AbstractButtonProps { @@ -83,16 +84,14 @@ class SharedVideoButton extends AbstractButton { * @returns {IProps} */ function _mapStateToProps(state: IReduxState) { - const { - disabled: sharedVideoBtnDisabled, - status: sharedVideoStatus - } = state['features/shared-video']; + const { ownerId, status: sharedVideoStatus } = state['features/shared-video']; + const localParticipantId = getLocalParticipant(state)?.id; + const isSharing = isSharingStatus(sharedVideoStatus ?? ''); return { - _isDisabled: Boolean(sharedVideoBtnDisabled), - _sharingVideo: isSharingStatus(sharedVideoStatus ?? '') + _isDisabled: isSharing && ownerId !== localParticipantId, + _sharingVideo: isSharing }; } - export default translate(connect(_mapStateToProps)(SharedVideoButton)); diff --git a/react/features/shared-video/middleware.native.ts b/react/features/shared-video/middleware.native.ts deleted file mode 100644 index fefd329e8ae2..000000000000 --- a/react/features/shared-video/middleware.native.ts +++ /dev/null @@ -1 +0,0 @@ -import './middleware.any'; diff --git a/react/features/shared-video/middleware.any.ts b/react/features/shared-video/middleware.ts similarity index 99% rename from react/features/shared-video/middleware.any.ts rename to react/features/shared-video/middleware.ts index 1aa8b27a17d7..dab57dd95757 100644 --- a/react/features/shared-video/middleware.any.ts +++ b/react/features/shared-video/middleware.ts @@ -22,7 +22,7 @@ import { setAllowedUrlDomians, setSharedVideoStatus, showConfirmPlayingDialog -} from './actions.any'; +} from './actions'; import { DEFAULT_ALLOWED_URL_DOMAINS, PLAYBACK_START, diff --git a/react/features/shared-video/middleware.web.ts b/react/features/shared-video/middleware.web.ts deleted file mode 100644 index 5c3eb360504a..000000000000 --- a/react/features/shared-video/middleware.web.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { CONFERENCE_JOIN_IN_PROGRESS } from '../base/conference/actionTypes'; -import { getLocalParticipant } from '../base/participants/functions'; -import MiddlewareRegistry from '../base/redux/MiddlewareRegistry'; - -import { setDisableButton } from './actions.web'; -import { PLAYBACK_STATUSES, SHARED_VIDEO } from './constants'; -import { isSharedVideoEnabled } from './functions'; - -import './middleware.any'; - -MiddlewareRegistry.register(({ dispatch, getState }) => next => action => { - const state = getState(); - const localParticipantId = getLocalParticipant(state)?.id; - - switch (action.type) { - case CONFERENCE_JOIN_IN_PROGRESS: { - if (!isSharedVideoEnabled(state)) { - break; - } - - const { conference } = action; - - conference.addCommandListener(SHARED_VIDEO, ({ attributes }: { attributes: - { from: string; state: string; }; }) => { - const { from } = attributes; - const status = attributes.state; - - if (status === PLAYBACK_STATUSES.PLAYING) { - if (localParticipantId !== from) { - dispatch(setDisableButton(true)); - } - } else if (status === 'stop') { - dispatch(setDisableButton(false)); - } - }); - break; - } - } - - return next(action); -}); diff --git a/react/features/shared-video/reducer.ts b/react/features/shared-video/reducer.ts index c3e98865f9ad..ca1ebebd0c91 100644 --- a/react/features/shared-video/reducer.ts +++ b/react/features/shared-video/reducer.ts @@ -4,7 +4,6 @@ import { RESET_SHARED_VIDEO_STATUS, SET_ALLOWED_URL_DOMAINS, SET_CONFIRM_SHOW_VIDEO, - SET_DISABLE_BUTTON, SET_SHARED_VIDEO_STATUS } from './actionTypes'; import { DEFAULT_ALLOWED_URL_DOMAINS } from './constants'; @@ -16,7 +15,6 @@ const initialState = { export interface ISharedVideoState { allowedUrlDomains: Array; confirmShowVideo?: boolean; - disabled?: boolean; muted?: boolean; ownerId?: string; status?: string; @@ -30,7 +28,7 @@ export interface ISharedVideoState { */ ReducerRegistry.register('features/shared-video', (state = initialState, action): ISharedVideoState => { - const { videoUrl, status, time, ownerId, disabled, muted, volume } = action; + const { videoUrl, status, time, ownerId, muted, volume } = action; switch (action.type) { case RESET_SHARED_VIDEO_STATUS: @@ -55,12 +53,6 @@ ReducerRegistry.register('features/shared-video', volume }; - case SET_DISABLE_BUTTON: - return { - ...state, - disabled - }; - case SET_ALLOWED_URL_DOMAINS: { return { ...state, diff --git a/react/features/video-menu/components/web/FakeParticipantContextMenu.tsx b/react/features/video-menu/components/web/FakeParticipantContextMenu.tsx index c5b1f2a403ab..91a962fd6e9f 100644 --- a/react/features/video-menu/components/web/FakeParticipantContextMenu.tsx +++ b/react/features/video-menu/components/web/FakeParticipantContextMenu.tsx @@ -9,7 +9,7 @@ import { isWhiteboardParticipant } from '../../../base/participants/functions'; import { IParticipant } from '../../../base/participants/types'; import ContextMenu from '../../../base/ui/components/web/ContextMenu'; import ContextMenuItemGroup from '../../../base/ui/components/web/ContextMenuItemGroup'; -import { stopSharedVideo } from '../../../shared-video/actions.any'; +import { stopSharedVideo } from '../../../shared-video/actions'; import { getParticipantMenuButtonsWithNotifyClick, showOverflowDrawer } from '../../../toolbox/functions.web'; import { NOTIFY_CLICK_MODE } from '../../../toolbox/types'; import { setWhiteboardOpen } from '../../../whiteboard/actions';