TelegramPWA/src/global/helpers/reactions.ts
2022-10-17 17:35:03 +02:00

15 lines
516 B
TypeScript

import type {
ApiMessage, ApiReactions,
} from '../../api/types';
import type { GlobalState } from '../types';
export function getMessageRecentReaction(message: Partial<ApiMessage>) {
return message.isOutgoing ? message.reactions?.recentReactions?.[0] : undefined;
}
export function checkIfHasUnreadReactions(global: GlobalState, reactions: ApiReactions) {
const { currentUserId } = global;
return reactions?.recentReactions?.some(
({ isUnread, userId }) => isUnread && userId !== currentUserId,
);
}