2019-07-16 14:30:29 +00:00
|
|
|
import moment from 'moment';
|
2020-10-30 17:35:07 +00:00
|
|
|
import { themes } from '../constants/colors';
|
2019-07-16 14:30:29 +00:00
|
|
|
|
|
|
|
import I18n from '../i18n';
|
2019-07-18 17:44:02 +00:00
|
|
|
|
|
|
|
export const isBlocked = (room) => {
|
|
|
|
if (room) {
|
|
|
|
const { t, blocked, blocker } = room;
|
|
|
|
if (t === 'd' && (blocked || blocker)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
2019-07-16 14:30:29 +00:00
|
|
|
export const capitalize = (s) => {
|
|
|
|
if (typeof s !== 'string') { return ''; }
|
|
|
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const formatDate = date => moment(date).calendar(null, {
|
|
|
|
lastDay: `[${ I18n.t('Yesterday') }]`,
|
|
|
|
sameDay: 'LT',
|
|
|
|
lastWeek: 'dddd',
|
2020-10-30 17:35:07 +00:00
|
|
|
sameElse: 'L'
|
2019-07-16 14:30:29 +00:00
|
|
|
});
|
2020-10-30 17:35:07 +00:00
|
|
|
|
|
|
|
export const formatDateThreads = date => moment(date).calendar(null, {
|
|
|
|
sameDay: 'LT',
|
|
|
|
lastDay: `[${ I18n.t('Yesterday') }] LT`,
|
|
|
|
lastWeek: 'dddd LT',
|
|
|
|
sameElse: 'LL'
|
|
|
|
});
|
|
|
|
|
|
|
|
export const getBadgeColor = ({ subscription, messageId, theme }) => {
|
|
|
|
if (subscription?.tunreadUser?.includes(messageId)) {
|
|
|
|
return themes[theme].mentionMeBackground;
|
|
|
|
}
|
|
|
|
if (subscription?.tunreadGroup?.includes(messageId)) {
|
|
|
|
return themes[theme].mentionGroupBackground;
|
|
|
|
}
|
|
|
|
if (subscription?.tunread?.includes(messageId)) {
|
|
|
|
return themes[theme].tunreadBackground;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export const makeThreadName = messageRecord => messageRecord.msg || messageRecord?.attachments[0]?.title;
|