mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-06 17:11:55 +00:00
Simplify how last message is handled.
This commit is contained in:
@@ -82,8 +82,9 @@ export const UserButton = observer((props: UserProps) => {
|
||||
</div>
|
||||
{
|
||||
<div className={styles.subText}>
|
||||
{channel?.last_message && alert ? (
|
||||
(channel.last_message as { short: string }).short
|
||||
{typeof channel?.last_message?.content === "string" &&
|
||||
alert ? (
|
||||
channel.last_message.content.slice(0, 32)
|
||||
) : (
|
||||
<UserStatus user={user} />
|
||||
)}
|
||||
@@ -162,8 +163,9 @@ export const ChannelButton = observer((props: ChannelProps) => {
|
||||
<div>{channel.name}</div>
|
||||
{channel.channel_type === "Group" && (
|
||||
<div className={styles.subText}>
|
||||
{channel.last_message && alert ? (
|
||||
(channel.last_message as { short: string }).short
|
||||
{typeof channel.last_message?.content === "string" &&
|
||||
alert ? (
|
||||
channel.last_message.content.slice(0, 32)
|
||||
) : (
|
||||
<Text
|
||||
id="quantities.members"
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user