Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(etherpad) fix loading Etherpad on web

Saúl Ibarra Corretgé83931183306e
diff --git a/react/features/etherpad/components/SharedDocumentButton.native.js b/react/features/etherpad/components/SharedDocumentButton.native.js
new file mode 100644
index 0000000000..2ed24006e1
--- /dev/null
+++ b/react/features/etherpad/components/SharedDocumentButton.native.js
@@ -0,0 +1,65 @@
+// @flow
+
+import { createToolbarEvent, sendAnalytics } from '../../analytics';
+import { translate } from '../../base/i18n';
+import { IconShareDoc } from '../../base/icons';
+import { connect } from '../../base/redux';
+import { AbstractButton, type AbstractButtonProps } from '../../base/toolbox/components';
+import { navigate } from '../../conference/components/native/ConferenceNavigationContainerRef';
+import { screen } from '../../conference/components/native/routes';
+
+
+type Props = AbstractButtonProps;
+
+/**
+ * Implements an {@link AbstractButton} to open the chat screen on mobile.
+ */
+class SharedDocumentButton extends AbstractButton<Props, *> {
+ accessibilityLabel = 'toolbar.accessibilityLabel.document';
+ icon = IconShareDoc;
+ label = 'toolbar.documentOpen';
+ tooltip = 'toolbar.documentOpen';
+
+ /**
+ * Handles clicking / pressing the button, and opens / closes the appropriate dialog.
+ *
+ * @private
+ * @returns {void}
+ */
+ _handleClick() {
+ const { handleClick } = this.props;
+
+ if (handleClick) {
+ handleClick();
+
+ return;
+ }
+
+ sendAnalytics(createToolbarEvent(
+ 'toggle.etherpad',
+ {
+ enable: true
+ }));
+
+ navigate(screen.conference.sharedDocument);
+ }
+}
+
+/**
+ * Maps part of the redux state to the component's props.
+ *
+ * @param {Object} state - The redux store/state.
+ * @param {Object} ownProps - The properties explicitly passed to the component
+ * instance.
+ * @returns {Object}
+ */
+function _mapStateToProps(state: Object, ownProps: Object) {
+ const { documentUrl } = state['features/etherpad'];
+ const { visible = Boolean(documentUrl) } = ownProps;
+
+ return {
+ visible
+ };
+}
+
+export default translate(connect(_mapStateToProps)(SharedDocumentButton));
diff --git a/react/features/etherpad/components/SharedDocumentButton.js b/react/features/etherpad/components/SharedDocumentButton.web.js
similarity index 88%
rename from react/features/etherpad/components/SharedDocumentButton.js
rename to react/features/etherpad/components/SharedDocumentButton.web.js
index 94a19ba1cd..eeb60a0bf6 100644
--- a/react/features/etherpad/components/SharedDocumentButton.js
+++ b/react/features/etherpad/components/SharedDocumentButton.web.js
@@ -1,12 +1,13 @@
// @flow
+import type { Dispatch } from 'redux';
+
import { createToolbarEvent, sendAnalytics } from '../../analytics';
import { translate } from '../../base/i18n';
import { IconShareDoc } from '../../base/icons';
import { connect } from '../../base/redux';
import { AbstractButton, type AbstractButtonProps } from '../../base/toolbox/components';
-import { navigate } from '../../conference/components/native/ConferenceNavigationContainerRef';
-import { screen } from '../../conference/components/native/routes';
+import { toggleDocument } from '../../etherpad/actions';
type Props = AbstractButtonProps & {
@@ -14,7 +15,12 @@ type Props = AbstractButtonProps & {
/**
* Whether the shared document is being edited or not.
*/
- _editing: boolean
+ _editing: boolean,
+
+ /**
+ * Redux dispatch function.
+ */
+ dispatch: Dispatch<any>,
};
/**
@@ -53,7 +59,7 @@ class SharedDocumentButton extends AbstractButton<Props, *> {
* @returns {void}
*/
_handleClick() {
- const { _editing, handleClick } = this.props;
+ const { _editing, dispatch, handleClick } = this.props;
if (handleClick) {
handleClick();
@@ -67,7 +73,7 @@ class SharedDocumentButton extends AbstractButton<Props, *> {
enable: !_editing
}));
- navigate(screen.conference.sharedDocument);
+ dispatch(toggleDocument());
}
/**
diff --git a/react/features/etherpad/components/index.native.js b/react/features/etherpad/components/index.native.js
index ce60f8cef6..fae33d1975 100644
--- a/react/features/etherpad/components/index.native.js
+++ b/react/features/etherpad/components/index.native.js
@@ -1,2 +1,2 @@
export { default as SharedDocument } from './native/SharedDocument';
-export { default as SharedDocumentButton } from './SharedDocumentButton';
+export { default as SharedDocumentButton } from './SharedDocumentButton.native';
diff --git a/react/features/etherpad/components/index.web.js b/react/features/etherpad/components/index.web.js
index 81707fd8b8..48fcd57be9 100644
--- a/react/features/etherpad/components/index.web.js
+++ b/react/features/etherpad/components/index.web.js
@@ -1 +1 @@
-export { default as SharedDocumentButton } from './SharedDocumentButton';
+export { default as SharedDocumentButton } from './SharedDocumentButton.web';