Skip to content

Commit

Permalink
optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
stephensu66 committed Jan 22, 2025
1 parent 80b4468 commit e73e732
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 123 deletions.
95 changes: 0 additions & 95 deletions frontend/src/components/dialog/add-video-link-dialog.js

This file was deleted.

29 changes: 1 addition & 28 deletions frontend/src/pages/sdoc/sdoc-editor/external-operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import toaster from '../../../components/toast';
import InternalLinkDialog from '../../../components/dialog/internal-link-dialog';
import ShareDialog from '../../../components/dialog/share-dialog';
import CreateFile from '../../../components/dialog/create-file-dialog';
import AddVideoLink from '../../../components/dialog/add-video-link-dialog';

const propTypes = {
repoID: PropTypes.string.isRequired,
Expand All @@ -34,8 +33,6 @@ class ExternalOperations extends React.Component {
fileType: '.sdoc',
editor: null,
insertSdocFileLink: null,
isShowAddVideoLinkDialog: false,
insertVideo: null
};
}

Expand All @@ -49,7 +46,6 @@ class ExternalOperations extends React.Component {
this.unsubscribeNewNotification = eventBus.subscribe(EXTERNAL_EVENT.NEW_NOTIFICATION, this.onNewNotification);
this.unsubscribeClearNotification = eventBus.subscribe(EXTERNAL_EVENT.CLEAR_NOTIFICATION, this.onClearNotification);
this.unsubscribeCreateSdocFile = eventBus.subscribe(EXTERNAL_EVENT.CREATE_SDOC_FILE, this.onCreateSdocFile);
this.unsubscribeAddVideoLink = eventBus.subscribe(EXTERNAL_EVENT.ADD_VIDEO_LINK, this.onAddVideoLink);
}

componentWillUnmount() {
Expand All @@ -62,18 +58,8 @@ class ExternalOperations extends React.Component {
this.unsubscribeNewNotification();
this.unsubscribeCreateSdocFile();
this.unsubscribeClearNotification();
this.unsubscribeAddVideoLink();
}

onAddVideoLink = (params) => {
if (params?.editor && params?.insertVideo) {
this.setState({ editor: params.editor, insertVideo: params.insertVideo });
}
this.setState({
isShowAddVideoLinkDialog: !this.state.isShowAddVideoLinkDialog
});
};

onInternalLinkToggle = (options) => {
if (options && options.internalLink) {
this.setState({ internalLink: options.internalLink });
Expand Down Expand Up @@ -178,16 +164,9 @@ class ExternalOperations extends React.Component {
});
};

onAddLink = (videoLink) => {
const { insertVideo, editor } = this.state;
if (insertVideo && editor) {
insertVideo(editor, [{ isEmbeddableLink: true }], [videoLink]);
}
};

render() {
const { repoID, docPath, docName, docPerm, dirPath } = this.props;
const { isShowInternalLinkDialog, isShowShareDialog, internalLink, isShowCreateFileDialog, fileType, isShowAddVideoLinkDialog } = this.state;
const { isShowInternalLinkDialog, isShowShareDialog, internalLink, isShowCreateFileDialog, fileType } = this.state;
return (
<>
{isShowInternalLinkDialog && (
Expand Down Expand Up @@ -217,12 +196,6 @@ class ExternalOperations extends React.Component {
toggleDialog={this.onCreateSdocFile}
/>
)}
{isShowAddVideoLinkDialog && (
<AddVideoLink
onAddLink={this.onAddLink}
toggleDialog={this.onAddVideoLink}
/>
)}
</>
);
}
Expand Down

0 comments on commit e73e732

Please sign in to comment.