2022-12-01 00:47:49 +08:00
|
|
|
import React, { useEffect, useState } from 'react';
|
2021-10-16 03:07:13 +08:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
|
|
import injectWbResizeEvent from '/imports/ui/components/presentation/resize-wrapper/component';
|
|
|
|
import Service from '/imports/ui/components/notes/service';
|
|
|
|
import PadContainer from '/imports/ui/components/pads/container';
|
|
|
|
import Styled from './styles';
|
2022-11-01 22:40:21 +08:00
|
|
|
import { PANELS, ACTIONS, LAYOUT_TYPE } from '../layout/enums';
|
2021-10-16 03:07:13 +08:00
|
|
|
import browserInfo from '/imports/utils/browserInfo';
|
2022-05-20 01:28:58 +08:00
|
|
|
import Header from '/imports/ui/components/common/control-header/component';
|
2022-10-31 22:05:09 +08:00
|
|
|
import NotesDropdown from '/imports/ui/components/notes/notes-dropdown/container';
|
2023-02-27 23:18:23 +08:00
|
|
|
import { isPresentationEnabled } from '../../services/features';
|
2021-10-16 03:07:13 +08:00
|
|
|
|
2024-03-07 01:28:18 +08:00
|
|
|
const CHAT_CONFIG = window.meetingClientSettings.public.chat;
|
|
|
|
const PUBLIC_CHAT_ID = CHAT_CONFIG.public_id;
|
|
|
|
const DELAY_UNMOUNT_SHARED_NOTES = window.meetingClientSettings.public.app.delayForUnmountOfSharedNote;
|
2021-10-16 03:07:13 +08:00
|
|
|
const intlMessages = defineMessages({
|
|
|
|
hide: {
|
|
|
|
id: 'app.notes.hide',
|
|
|
|
description: 'Label for hiding shared notes button',
|
|
|
|
},
|
|
|
|
title: {
|
|
|
|
id: 'app.notes.title',
|
|
|
|
description: 'Title for the shared notes',
|
|
|
|
},
|
2022-10-31 22:05:09 +08:00
|
|
|
unpinNotes: {
|
|
|
|
id: 'app.notes.notesDropdown.unpinNotes',
|
|
|
|
description: 'Label for unpin shared notes button',
|
|
|
|
},
|
2021-10-16 03:07:13 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
intl: PropTypes.shape({
|
|
|
|
formatMessage: PropTypes.func.isRequired,
|
|
|
|
}).isRequired,
|
|
|
|
isRTL: PropTypes.bool.isRequired,
|
|
|
|
hasPermission: PropTypes.bool.isRequired,
|
|
|
|
isResizing: PropTypes.bool.isRequired,
|
|
|
|
layoutContextDispatch: PropTypes.func.isRequired,
|
2022-11-01 22:40:21 +08:00
|
|
|
sidebarContent: PropTypes.object.isRequired,
|
|
|
|
sharedNotesOutput: PropTypes.object.isRequired,
|
|
|
|
area: PropTypes.string,
|
|
|
|
layoutType: PropTypes.string,
|
2021-10-16 03:07:13 +08:00
|
|
|
};
|
|
|
|
|
2022-10-24 21:11:28 +08:00
|
|
|
const defaultProps = {
|
|
|
|
area: 'sidebarContent',
|
2022-11-01 22:40:21 +08:00
|
|
|
layoutType: null,
|
2022-10-24 21:11:28 +08:00
|
|
|
};
|
|
|
|
|
2022-12-01 00:47:49 +08:00
|
|
|
let timoutRef = null;
|
2023-01-17 22:52:27 +08:00
|
|
|
const sidebarContentToIgnoreDelay = ['captions'];
|
2021-10-16 03:07:13 +08:00
|
|
|
const Notes = ({
|
|
|
|
hasPermission,
|
|
|
|
intl,
|
|
|
|
isRTL,
|
|
|
|
layoutContextDispatch,
|
|
|
|
isResizing,
|
2022-10-24 21:11:28 +08:00
|
|
|
area,
|
2022-11-01 22:40:21 +08:00
|
|
|
layoutType,
|
2022-10-24 21:11:28 +08:00
|
|
|
sidebarContent,
|
|
|
|
sharedNotesOutput,
|
2022-11-03 19:56:03 +08:00
|
|
|
amIPresenter,
|
2022-12-01 00:47:49 +08:00
|
|
|
isToSharedNotesBeShow,
|
2023-01-19 04:10:22 +08:00
|
|
|
shouldShowSharedNotesOnPresentationArea,
|
2024-02-23 21:42:12 +08:00
|
|
|
isGridEnabled,
|
2021-10-16 03:07:13 +08:00
|
|
|
}) => {
|
2022-12-01 00:47:49 +08:00
|
|
|
const [shouldRenderNotes, setShouldRenderNotes] = useState(false);
|
2023-06-06 00:42:24 +08:00
|
|
|
|
2021-10-16 03:07:13 +08:00
|
|
|
const { isChrome } = browserInfo;
|
2022-10-24 21:11:28 +08:00
|
|
|
const isOnMediaArea = area === 'media';
|
|
|
|
const style = isOnMediaArea ? {
|
|
|
|
position: 'absolute',
|
|
|
|
...sharedNotesOutput,
|
|
|
|
} : {};
|
2023-01-17 19:47:34 +08:00
|
|
|
|
2022-12-01 00:47:49 +08:00
|
|
|
const isHidden = (isOnMediaArea && (style.width === 0 || style.height === 0))
|
2023-06-06 00:42:24 +08:00
|
|
|
|| (!isToSharedNotesBeShow
|
|
|
|
&& !sidebarContentToIgnoreDelay.includes(sidebarContent.sidebarContentPanel))
|
|
|
|
|| shouldShowSharedNotesOnPresentationArea;
|
2022-10-24 21:11:28 +08:00
|
|
|
|
2023-02-01 01:52:17 +08:00
|
|
|
if (isHidden && !isOnMediaArea) {
|
2023-01-19 21:44:47 +08:00
|
|
|
style.padding = 0;
|
2023-01-25 21:05:14 +08:00
|
|
|
style.display = 'none';
|
2023-01-19 21:44:47 +08:00
|
|
|
}
|
2024-02-23 21:42:12 +08:00
|
|
|
if (isGridEnabled && !sidebarContent.isOpen) {
|
|
|
|
style.padding = 0;
|
|
|
|
}
|
2022-12-01 00:47:49 +08:00
|
|
|
useEffect(() => {
|
|
|
|
if (isToSharedNotesBeShow) {
|
|
|
|
setShouldRenderNotes(true);
|
|
|
|
clearTimeout(timoutRef);
|
|
|
|
} else {
|
|
|
|
timoutRef = setTimeout(() => {
|
|
|
|
setShouldRenderNotes(false);
|
2023-01-19 04:10:22 +08:00
|
|
|
}, (sidebarContentToIgnoreDelay.includes(sidebarContent.sidebarContentPanel)
|
2023-06-06 00:42:24 +08:00
|
|
|
|| shouldShowSharedNotesOnPresentationArea)
|
2023-01-19 04:10:22 +08:00
|
|
|
? 0 : DELAY_UNMOUNT_SHARED_NOTES);
|
2022-12-01 00:47:49 +08:00
|
|
|
}
|
2023-01-25 00:48:47 +08:00
|
|
|
return () => clearTimeout(timoutRef);
|
2023-01-19 04:10:22 +08:00
|
|
|
}, [isToSharedNotesBeShow, sidebarContent.sidebarContentPanel]);
|
2022-10-24 21:11:28 +08:00
|
|
|
useEffect(() => {
|
|
|
|
if (
|
|
|
|
isOnMediaArea
|
2023-02-27 23:18:23 +08:00
|
|
|
&& (sidebarContent.isOpen || !isPresentationEnabled())
|
|
|
|
&& (sidebarContent.sidebarContentPanel === PANELS.SHARED_NOTES || !isPresentationEnabled())
|
2022-10-24 21:11:28 +08:00
|
|
|
) {
|
2022-11-01 22:40:21 +08:00
|
|
|
if (layoutType === LAYOUT_TYPE.VIDEO_FOCUS) {
|
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_SIDEBAR_CONTENT_PANEL,
|
|
|
|
value: PANELS.CHAT,
|
|
|
|
});
|
2022-10-28 04:15:11 +08:00
|
|
|
|
2022-11-01 22:40:21 +08:00
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_ID_CHAT_OPEN,
|
|
|
|
value: PUBLIC_CHAT_ID,
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_SIDEBAR_CONTENT_IS_OPEN,
|
|
|
|
value: false,
|
|
|
|
});
|
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_SIDEBAR_CONTENT_PANEL,
|
|
|
|
value: PANELS.NONE,
|
|
|
|
});
|
|
|
|
}
|
2022-10-28 04:15:11 +08:00
|
|
|
|
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_NOTES_IS_PINNED,
|
|
|
|
value: true,
|
|
|
|
});
|
2023-02-23 03:32:57 +08:00
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_PRESENTATION_IS_OPEN,
|
|
|
|
value: true,
|
|
|
|
});
|
2022-10-28 04:15:11 +08:00
|
|
|
|
|
|
|
return () => {
|
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_NOTES_IS_PINNED,
|
|
|
|
value: false,
|
|
|
|
});
|
2023-04-11 03:25:19 +08:00
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_PRESENTATION_IS_OPEN,
|
|
|
|
value: Session.get('presentationLastState'),
|
|
|
|
});
|
2022-10-28 04:15:11 +08:00
|
|
|
};
|
2023-06-28 00:53:21 +08:00
|
|
|
} if (shouldShowSharedNotesOnPresentationArea) {
|
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_NOTES_IS_PINNED,
|
|
|
|
value: true,
|
|
|
|
});
|
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_PRESENTATION_IS_OPEN,
|
|
|
|
value: true,
|
|
|
|
});
|
2022-10-24 21:11:28 +08:00
|
|
|
}
|
|
|
|
}, []);
|
2021-10-16 03:07:13 +08:00
|
|
|
|
2022-11-03 19:56:03 +08:00
|
|
|
const renderHeaderOnMedia = () => {
|
|
|
|
return amIPresenter ? (
|
|
|
|
<Styled.Header
|
|
|
|
rightButtonProps={{
|
|
|
|
'aria-label': intl.formatMessage(intlMessages.unpinNotes),
|
|
|
|
'data-test': 'unpinNotes',
|
|
|
|
icon: 'close',
|
|
|
|
label: intl.formatMessage(intlMessages.unpinNotes),
|
|
|
|
onClick: () => {
|
|
|
|
Service.pinSharedNotes(false);
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
) : null;
|
|
|
|
};
|
|
|
|
|
2023-01-19 21:44:47 +08:00
|
|
|
return (shouldRenderNotes || shouldShowSharedNotesOnPresentationArea) && (
|
2023-06-06 00:42:24 +08:00
|
|
|
<Styled.Notes
|
|
|
|
data-test="notes"
|
|
|
|
isChrome={isChrome}
|
|
|
|
style={style}
|
|
|
|
>
|
2022-10-24 21:11:28 +08:00
|
|
|
{!isOnMediaArea ? (
|
|
|
|
<Header
|
|
|
|
leftButtonProps={{
|
|
|
|
onClick: () => {
|
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_SIDEBAR_CONTENT_IS_OPEN,
|
|
|
|
value: false,
|
|
|
|
});
|
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_SIDEBAR_CONTENT_PANEL,
|
|
|
|
value: PANELS.NONE,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
'data-test': 'hideNotesLabel',
|
|
|
|
'aria-label': intl.formatMessage(intlMessages.hide),
|
|
|
|
label: intl.formatMessage(intlMessages.title),
|
|
|
|
}}
|
|
|
|
customRightButton={
|
2022-10-31 22:05:09 +08:00
|
|
|
<NotesDropdown />
|
2022-10-24 21:11:28 +08:00
|
|
|
}
|
|
|
|
/>
|
2022-11-03 19:56:03 +08:00
|
|
|
) : renderHeaderOnMedia()}
|
2021-10-16 03:07:13 +08:00
|
|
|
<PadContainer
|
|
|
|
externalId={Service.ID}
|
|
|
|
hasPermission={hasPermission}
|
|
|
|
isResizing={isResizing}
|
|
|
|
isRTL={isRTL}
|
|
|
|
/>
|
|
|
|
</Styled.Notes>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
Notes.propTypes = propTypes;
|
2022-10-24 21:11:28 +08:00
|
|
|
Notes.defaultProps = defaultProps;
|
2021-10-16 03:07:13 +08:00
|
|
|
|
|
|
|
export default injectWbResizeEvent(injectIntl(Notes));
|