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)) {
|
2020-12-17 17:39:45 +00:00
|
|
|
return themes[theme].mentionMeColor;
|
2020-10-30 17:35:07 +00:00
|
|
|
}
|
|
|
|
if (subscription?.tunreadGroup?.includes(messageId)) {
|
2020-12-17 17:39:45 +00:00
|
|
|
return themes[theme].mentionGroupColor;
|
2020-10-30 17:35:07 +00:00
|
|
|
}
|
|
|
|
if (subscription?.tunread?.includes(messageId)) {
|
2020-12-17 17:39:45 +00:00
|
|
|
return themes[theme].tunreadColor;
|
2020-10-30 17:35:07 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export const makeThreadName = messageRecord => messageRecord.msg || messageRecord?.attachments[0]?.title;
|
2021-05-12 19:01:29 +00:00
|
|
|
|
|
|
|
export const isTeamRoom = ({ teamId, joined }) => teamId && joined;
|