2022-04-15 02:51:59 +00:00
|
|
|
import { IUnreadBadge } from '.';
|
|
|
|
import { themes } from '../../lib/constants/colors';
|
2022-04-12 16:27:05 +00:00
|
|
|
import { TSupportedThemes } from '../../theme';
|
2020-10-30 16:15:58 +00:00
|
|
|
|
2022-04-15 02:51:59 +00:00
|
|
|
interface IGetUnreadStyle extends Omit<IUnreadBadge, 'small' | 'style'> {
|
2022-04-12 16:27:05 +00:00
|
|
|
theme: TSupportedThemes;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const getUnreadStyle = ({
|
|
|
|
unread,
|
|
|
|
userMentions,
|
|
|
|
groupMentions,
|
|
|
|
theme,
|
|
|
|
tunread,
|
|
|
|
tunreadUser,
|
|
|
|
tunreadGroup
|
|
|
|
}: IGetUnreadStyle) => {
|
2021-09-13 20:41:05 +00:00
|
|
|
if ((!unread || unread <= 0) && !tunread?.length) {
|
2020-10-30 16:15:58 +00:00
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2020-12-17 17:39:45 +00:00
|
|
|
let backgroundColor = themes[theme].unreadColor;
|
2020-10-30 16:15:58 +00:00
|
|
|
const color = themes[theme].buttonText;
|
2022-04-12 16:27:05 +00:00
|
|
|
if ((userMentions && userMentions > 0) || tunreadUser?.length) {
|
2020-12-17 17:39:45 +00:00
|
|
|
backgroundColor = themes[theme].mentionMeColor;
|
2022-04-12 16:27:05 +00:00
|
|
|
} else if ((groupMentions && groupMentions > 0) || tunreadGroup?.length) {
|
2020-12-17 17:39:45 +00:00
|
|
|
backgroundColor = themes[theme].mentionGroupColor;
|
2022-04-12 16:27:05 +00:00
|
|
|
} else if (tunread && tunread?.length > 0) {
|
2020-12-17 17:39:45 +00:00
|
|
|
backgroundColor = themes[theme].tunreadColor;
|
2020-10-30 16:15:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
2021-09-13 20:41:05 +00:00
|
|
|
backgroundColor,
|
|
|
|
color
|
2020-10-30 16:15:58 +00:00
|
|
|
};
|
|
|
|
};
|