Use delta for mark as unread (#6127)
This commit is contained in:
parent
73d23ea515
commit
28b86e9c24
1 changed files with 6 additions and 4 deletions
|
|
@ -255,7 +255,7 @@ export async function handlePostDeleted(serverUrl: string, msg: WebSocketMessage
|
|||
}
|
||||
|
||||
export async function handlePostUnread(serverUrl: string, msg: WebSocketMessage) {
|
||||
const {channel_id: channelId} = msg.broadcast;
|
||||
const {channel_id: channelId, team_id: teamId} = msg.broadcast;
|
||||
const {mention_count: mentionCount, msg_count: msgCount, last_viewed_at: lastViewedAt} = msg.data;
|
||||
const database = DatabaseManager.serverDatabases[serverUrl]?.database;
|
||||
if (!database) {
|
||||
|
|
@ -264,8 +264,10 @@ export async function handlePostUnread(serverUrl: string, msg: WebSocketMessage)
|
|||
|
||||
const myChannel = await getMyChannel(database, channelId);
|
||||
if (!myChannel?.manuallyUnread) {
|
||||
// We used to fetch the channel to get the delta on the message count
|
||||
// We just need to identify that there are unread messages, the exact number is uninportant
|
||||
markChannelAsUnread(serverUrl, channelId, msgCount, mentionCount, lastViewedAt);
|
||||
const {channels} = await fetchMyChannel(serverUrl, teamId, channelId, true);
|
||||
const channel = channels?.[0];
|
||||
const postNumber = channel?.total_msg_count;
|
||||
const delta = postNumber ? postNumber - msgCount : msgCount;
|
||||
markChannelAsUnread(serverUrl, channelId, delta, mentionCount, lastViewedAt);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue