diff --git a/frontend/src/pages/sdoc/sdoc-editor/external-operations.js b/frontend/src/pages/sdoc/sdoc-editor/external-operations.js index 54c801b853..1c531ea4d7 100644 --- a/frontend/src/pages/sdoc/sdoc-editor/external-operations.js +++ b/frontend/src/pages/sdoc/sdoc-editor/external-operations.js @@ -14,7 +14,8 @@ const propTypes = { docPerm: PropTypes.string.isRequired, isStarred: PropTypes.bool.isRequired, toggleStar: PropTypes.func.isRequired, - unmarkDraft: PropTypes.func.isRequired + unmarkDraft: PropTypes.func.isRequired, + onNewNotification: PropTypes.func.isRequired }; class ExternalOperations extends React.Component { @@ -33,8 +34,9 @@ class ExternalOperations extends React.Component { this.unsubscribeStar = eventBus.subscribe(EXTERNAL_EVENT.TOGGLE_STAR, this.toggleStar); this.unsubscribeUnmark = eventBus.subscribe(EXTERNAL_EVENT.UNMARK_AS_DRAFT, this.unmark); this.unsubscribeShare = eventBus.subscribe(EXTERNAL_EVENT.SHARE_SDOC, this.onShareToggle); - this.unsubscribeShare = eventBus.subscribe(EXTERNAL_EVENT.FREEZE_DOCUMENT, this.onFreezeDocument); - this.unsubscribeShare = eventBus.subscribe(EXTERNAL_EVENT.UNFREEZE, this.unFreeze); + 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); } componentWillUnmount() { @@ -42,6 +44,9 @@ class ExternalOperations extends React.Component { this.unsubscribeStar(); this.unsubscribeUnmark(); this.unsubscribeShare(); + this.unsubscribeFreezeDocument(); + this.unsubscribeUnfreeze(); + this.unsubscribeNewNotification(); } onInternalLinkToggle = () => { @@ -103,6 +108,10 @@ class ExternalOperations extends React.Component { }); }; + onNewNotification = () => { + this.props.onNewNotification(); + }; + render() { const { repoID, docPath, docName, docPerm } = this.props; const { isShowInternalLinkDialog, isShowShareDialog } = this.state; diff --git a/frontend/src/pages/sdoc/sdoc-editor/index.js b/frontend/src/pages/sdoc/sdoc-editor/index.js index 39ca48ef99..622aabde8b 100644 --- a/frontend/src/pages/sdoc/sdoc-editor/index.js +++ b/frontend/src/pages/sdoc/sdoc-editor/index.js @@ -15,9 +15,7 @@ export default class SdocEditor extends React.Component { } componentDidMount() { - const { docName } = window.seafile; - const fileIcon = Utils.getFileIconUrl(docName, 192); - document.getElementById('favicon').href = fileIcon; + this.onSetFavicon(); } toggleStar = (isStarred) => { @@ -28,6 +26,19 @@ export default class SdocEditor extends React.Component { this.setState({isDraft: false}); }; + onSetFavicon = (suffix) => { + let { docName } = window.seafile; + if (suffix) { + docName = docName + suffix; + } + const fileIcon = Utils.getFileIconUrl(docName, 192); + document.getElementById('favicon').href = fileIcon; + }; + + onNewNotification = () => { + this.onSetFavicon('_notification'); + }; + render() { const { repoID, docPath, docName, docPerm } = window.seafile; const { isStarred, isDraft } = this.state; @@ -42,6 +53,7 @@ export default class SdocEditor extends React.Component { isStarred={isStarred} toggleStar={this.toggleStar} unmarkDraft={this.unmarkDraft} + onNewNotification={this.onNewNotification} /> ); diff --git a/frontend/src/utils/utils.js b/frontend/src/utils/utils.js index 75600cef60..cd3dff5c05 100644 --- a/frontend/src/utils/utils.js +++ b/frontend/src/utils/utils.js @@ -106,6 +106,7 @@ export const Utils = { // default 'default' : 'file.png', 'sdoc': 'sdoc.png', + 'sdoc_notification': 'sdoc_notification.ico' }, // check if a file is an image diff --git a/media/img/file/192/sdoc_notification.ico b/media/img/file/192/sdoc_notification.ico new file mode 100644 index 0000000000..2942705a02 Binary files /dev/null and b/media/img/file/192/sdoc_notification.ico differ