Skip to content

Commit

Permalink
Merge pull request #5880 from haiwen/update-favicon
Browse files Browse the repository at this point in the history
update-favicon
  • Loading branch information
shuntian authored Jan 6, 2024
2 parents 9ba465f + 9349c83 commit d41c77c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
15 changes: 12 additions & 3 deletions frontend/src/pages/sdoc/sdoc-editor/external-operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -34,15 +35,19 @@ 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() {
this.unsubscribeInternalLinkEvent();
this.unsubscribeStar();
this.unsubscribeUnmark();
this.unsubscribeShare();
this.unsubscribeFreezeDocument();
this.unsubscribeUnfreeze();
this.unsubscribeNewNotification();
}

onInternalLinkToggle = (options) => {
Expand Down Expand Up @@ -107,6 +112,10 @@ class ExternalOperations extends React.Component {
});
};

onNewNotification = () => {
this.props.onNewNotification();
};

render() {
const { repoID, docPath, docName, docPerm } = this.props;
const { isShowInternalLinkDialog, isShowShareDialog, internalLink } = this.state;
Expand Down
18 changes: 15 additions & 3 deletions frontend/src/pages/sdoc/sdoc-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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;
Expand All @@ -42,6 +53,7 @@ export default class SdocEditor extends React.Component {
isStarred={isStarred}
toggleStar={this.toggleStar}
unmarkDraft={this.unmarkDraft}
onNewNotification={this.onNewNotification}
/>
</Fragment>
);
Expand Down
1 change: 1 addition & 0 deletions frontend/src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added media/img/file/192/sdoc_notification.ico
Binary file not shown.

0 comments on commit d41c77c

Please sign in to comment.