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>
Этот коммит содержится в:
Tanmay Vardhaman Thole
2023-10-19 14:15:14 +05:30
коммит произвёл GitHub
родитель 98b72ffbf5
Коммит 4eb30f517c
2 изменённых файлов: 10 добавлений и 11 удалений

Просмотреть файл

@@ -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('');
});
});

Просмотреть файл

@@ -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);