1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-24 09:41:04 +00:00

fix: optimize code

This commit is contained in:
liuhongbo 2024-03-01 18:15:01 +08:00
parent fb17628cc8
commit d6142e0432
2 changed files with 15 additions and 15 deletions

View File

@ -19,7 +19,7 @@ const propTypes = {
toggleStar: PropTypes.func.isRequired,
unmarkDraft: PropTypes.func.isRequired,
onNewNotification: PropTypes.func.isRequired,
onNotificationCleared: PropTypes.func.isRequired
onClearNotification: PropTypes.func.isRequired
};
class ExternalOperations extends React.Component {
@ -44,7 +44,7 @@ class ExternalOperations extends React.Component {
this.unsubscribeFreezeDocument = eventBus.subscribe(EXTERNAL_EVENT.FREEZE_DOCUMENT, this.onFreezeDocument);
this.unsubscribeUnfreeze = eventBus.subscribe(EXTERNAL_EVENT.UNFREEZE, this.unFreeze);
this.unsubscribeNewNotification = eventBus.subscribe(EXTERNAL_EVENT.NEW_NOTIFICATION, this.onNewNotification);
this.unsubscribeClearNotification = eventBus.subscribe(EXTERNAL_EVENT.CLEAR_NOTIFICATION, this.onNotificationCleared);
this.unsubscribeClearNotification = eventBus.subscribe(EXTERNAL_EVENT.CLEAR_NOTIFICATION, this.onClearNotification);
this.unsubscribeCreateSdocFile = eventBus.subscribe(EXTERNAL_EVENT.CREATE_SDOC_FILE, this.onCreateSdocFile);
}
@ -62,9 +62,9 @@ class ExternalOperations extends React.Component {
onInternalLinkToggle = (options) => {
if (options && options.internalLink) {
this.setState({internalLink: options.internalLink});
this.setState({ internalLink: options.internalLink });
}
this.setState({isShowInternalLinkDialog: !this.state.isShowInternalLinkDialog});
this.setState({ isShowInternalLinkDialog: !this.state.isShowInternalLinkDialog });
};
unmark = () => {
@ -78,7 +78,7 @@ class ExternalOperations extends React.Component {
};
toggleStar = () => {
const { isStarred, repoID, docPath } = this.props;
const { isStarred, repoID, docPath } = this.props;
if (isStarred) {
seafileAPI.unstarItem(repoID, docPath).then((res) => {
this.props.toggleStar(false);
@ -97,7 +97,7 @@ class ExternalOperations extends React.Component {
};
onShareToggle = () => {
this.setState({isShowShareDialog: !this.state.isShowShareDialog});
this.setState({ isShowShareDialog: !this.state.isShowShareDialog });
};
onFreezeDocument = () => {
@ -126,13 +126,13 @@ class ExternalOperations extends React.Component {
this.props.onNewNotification();
};
onNotificationCleared = () => {
this.props.onNotificationCleared();
onClearNotification = () => {
this.props.onClearNotification();
};
onCreateSdocFile = (params) => {
if (params?.newFileName) {
this.setState({fileType: `${params.newFileName}.sdoc`});
this.setState({ fileType: `${params.newFileName}.sdoc` });
}
this.setState({
isShowCreateFileDialog: !this.state.isShowCreateFileDialog
@ -151,7 +151,7 @@ class ExternalOperations extends React.Component {
let repoID = this.props.repoID;
seafileAPI.createFile(repoID, filePath, isMarkdownDraft).then((res) => {
const eventBus = EventBus.getInstance();
eventBus.dispatch(EXTERNAL_EVENT.INSERT_LINK, {data: res.data});
eventBus.dispatch(EXTERNAL_EVENT.INSERT_LINK, { data: res.data });
}).catch((error) => {
let errMessage = Utils.getErrorMsg(error);
toaster.danger(errMessage);

View File

@ -23,11 +23,11 @@ export default class SdocEditor extends React.Component {
}
toggleStar = (isStarred) => {
this.setState({isStarred: isStarred});
this.setState({ isStarred: isStarred });
};
unmarkDraft = () => {
this.setState({isDraft: false});
this.setState({ isDraft: false });
};
onSetFavicon = (suffix) => {
@ -43,7 +43,7 @@ export default class SdocEditor extends React.Component {
this.onSetFavicon('_notification');
};
onNotificationCleared = () => {
onClearNotification = () => {
this.onSetFavicon();
};
@ -59,7 +59,7 @@ export default class SdocEditor extends React.Component {
getDirentList = () => {
const { repoID } = window.seafile;
const path = this.getDirPath();
seafileAPI.listDir(repoID, path, {'with_thumbnail': true}).then(res => {
seafileAPI.listDir(repoID, path, { 'with_thumbnail': true }).then(res => {
let direntList = [];
res.data.dirent_list.forEach(item => {
let dirent = new Dirent(item);
@ -91,7 +91,7 @@ export default class SdocEditor extends React.Component {
toggleStar={this.toggleStar}
unmarkDraft={this.unmarkDraft}
onNewNotification={this.onNewNotification}
onNotificationCleared={this.onNotificationCleared}
onClearNotification={this.onClearNotification}
/>
</Fragment>
);