Simplify how last message is handled.

This commit is contained in:
Paul
2021-09-14 15:07:42 +01:00
parent 45c7cd0307
commit cc45b9e255
4 changed files with 12 additions and 25 deletions

View File

@@ -49,22 +49,7 @@ export function useUnreads({ channel, unreads }: UnreadProps) {
}
export function mapChannelWithUnread(channel: Channel, unreads: Unreads) {
let last_message_id;
if (
channel.channel_type === "DirectMessage" ||
channel.channel_type === "Group"
) {
last_message_id = (channel.last_message as { _id: string })?._id;
} else if (channel.channel_type === "TextChannel") {
last_message_id = channel.last_message as string;
} else {
return {
channel,
unread: undefined,
alertCount: undefined,
timestamp: channel._id,
};
}
const last_message_id = channel.last_message_id;
let unread: "mention" | "unread" | undefined;
let alertCount: undefined | number;