Skip to content

Commit d41c77c

Browse files
authored
Merge pull request #5880 from haiwen/update-favicon
update-favicon
2 parents 9ba465f + 9349c83 commit d41c77c

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

frontend/src/pages/sdoc/sdoc-editor/external-operations.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ const propTypes = {
1414
docPerm: PropTypes.string.isRequired,
1515
isStarred: PropTypes.bool.isRequired,
1616
toggleStar: PropTypes.func.isRequired,
17-
unmarkDraft: PropTypes.func.isRequired
17+
unmarkDraft: PropTypes.func.isRequired,
18+
onNewNotification: PropTypes.func.isRequired
1819
};
1920

2021
class ExternalOperations extends React.Component {
@@ -34,15 +35,19 @@ class ExternalOperations extends React.Component {
3435
this.unsubscribeStar = eventBus.subscribe(EXTERNAL_EVENT.TOGGLE_STAR, this.toggleStar);
3536
this.unsubscribeUnmark = eventBus.subscribe(EXTERNAL_EVENT.UNMARK_AS_DRAFT, this.unmark);
3637
this.unsubscribeShare = eventBus.subscribe(EXTERNAL_EVENT.SHARE_SDOC, this.onShareToggle);
37-
this.unsubscribeShare = eventBus.subscribe(EXTERNAL_EVENT.FREEZE_DOCUMENT, this.onFreezeDocument);
38-
this.unsubscribeShare = eventBus.subscribe(EXTERNAL_EVENT.UNFREEZE, this.unFreeze);
38+
this.unsubscribeFreezeDocument = eventBus.subscribe(EXTERNAL_EVENT.FREEZE_DOCUMENT, this.onFreezeDocument);
39+
this.unsubscribeUnfreeze = eventBus.subscribe(EXTERNAL_EVENT.UNFREEZE, this.unFreeze);
40+
this.unsubscribeNewNotification = eventBus.subscribe(EXTERNAL_EVENT.NEW_NOTIFICATION, this.onNewNotification);
3941
}
4042

4143
componentWillUnmount() {
4244
this.unsubscribeInternalLinkEvent();
4345
this.unsubscribeStar();
4446
this.unsubscribeUnmark();
4547
this.unsubscribeShare();
48+
this.unsubscribeFreezeDocument();
49+
this.unsubscribeUnfreeze();
50+
this.unsubscribeNewNotification();
4651
}
4752

4853
onInternalLinkToggle = (options) => {
@@ -107,6 +112,10 @@ class ExternalOperations extends React.Component {
107112
});
108113
};
109114

115+
onNewNotification = () => {
116+
this.props.onNewNotification();
117+
};
118+
110119
render() {
111120
const { repoID, docPath, docName, docPerm } = this.props;
112121
const { isShowInternalLinkDialog, isShowShareDialog, internalLink } = this.state;

frontend/src/pages/sdoc/sdoc-editor/index.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ export default class SdocEditor extends React.Component {
1515
}
1616

1717
componentDidMount() {
18-
const { docName } = window.seafile;
19-
const fileIcon = Utils.getFileIconUrl(docName, 192);
20-
document.getElementById('favicon').href = fileIcon;
18+
this.onSetFavicon();
2119
}
2220

2321
toggleStar = (isStarred) => {
@@ -28,6 +26,19 @@ export default class SdocEditor extends React.Component {
2826
this.setState({isDraft: false});
2927
};
3028

29+
onSetFavicon = (suffix) => {
30+
let { docName } = window.seafile;
31+
if (suffix) {
32+
docName = docName + suffix;
33+
}
34+
const fileIcon = Utils.getFileIconUrl(docName, 192);
35+
document.getElementById('favicon').href = fileIcon;
36+
};
37+
38+
onNewNotification = () => {
39+
this.onSetFavicon('_notification');
40+
};
41+
3142
render() {
3243
const { repoID, docPath, docName, docPerm } = window.seafile;
3344
const { isStarred, isDraft } = this.state;
@@ -42,6 +53,7 @@ export default class SdocEditor extends React.Component {
4253
isStarred={isStarred}
4354
toggleStar={this.toggleStar}
4455
unmarkDraft={this.unmarkDraft}
56+
onNewNotification={this.onNewNotification}
4557
/>
4658
</Fragment>
4759
);

frontend/src/utils/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export const Utils = {
106106
// default
107107
'default' : 'file.png',
108108
'sdoc': 'sdoc.png',
109+
'sdoc_notification': 'sdoc_notification.ico'
109110
},
110111

111112
// check if a file is an image
4.19 KB
Binary file not shown.

0 commit comments

Comments
 (0)