migrate notify counts component from class based to function based comp (#24794)

* migrate notify counts component to function comp

* comment resolved

* Update webapp/channels/src/components/notify_counts/notify_counts.tsx

* Fixing tests

* Removing unnecessary call

---------

Co-authored-by: Jesús Espino <jespinog@gmail.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
Tanmay Vardhaman Thole 2023-10-19 14:15:14 +05:30 committed by GitHub
parent 98b72ffbf5
commit 4eb30f517c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 11 deletions

View File

@ -37,6 +37,6 @@ describe('components/notify_counts', () => {
const {mountOptions} = mockStore();
const wrapper = mount(<NotifyCounts/>, mountOptions);
expect(wrapper.isEmptyRender()).toBe(true);
expect(wrapper.html()).toBe('');
});
});

View File

@ -4,15 +4,14 @@
import React from 'react';
import type {BasicUnreadMeta} from 'mattermost-redux/selectors/entities/channels';
type Props = BasicUnreadMeta;
export default class NotifyCounts extends React.PureComponent<Props> {
render() {
if (this.props.unreadMentionCount) {
return <span className='badge badge-notify'>{this.props.unreadMentionCount}</span>;
} else if (this.props.isUnread) {
return <span className='badge badge-notify'>{'•'}</span>;
}
return null;
const NotifyCounts = ({unreadMentionCount, isUnread}: BasicUnreadMeta) => {
if (unreadMentionCount) {
return <span className='badge badge-notify'>{unreadMentionCount}</span>;
} else if (isUnread) {
return <span className='badge badge-notify'>{'•'}</span>;
}
}
return null;
};
export default React.memo(NotifyCounts);