* Global threads * Added translations * User avatar stack * In-Channel experience * Misc Fixes * Fixed fetchPostThread & added observer * using the observable for participants & check fix * Test case fix * Fix tablet view thread screen switching * No back button for tablets * folders for thread options only if needed * Using the existing observable * Users stack refactor fix * Reusing the user component * Refactor fix * Fixes double loaders when empty threads * Feedback * Moved some post options to common post options * Combined follow/unfollow functions * Feedback fixes * Addressing Feedback * Merge fix * Threads button component moved * Addressing feedbackk * Not rendering message when it's empty, removed unwanted Props exports * Addressing feedbac * Updated snapshot * Added emoji to removemarkdown component * Moved MD rendering into the component Co-authored-by: Mattermod <mattermod@users.noreply.github.com> Co-authored-by: koox00 <3829551+koox00@users.noreply.github.com>
65 lines
2.1 KiB
TypeScript
65 lines
2.1 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {markTeamThreadsAsRead, processReceivedThreads, updateThread} from '@actions/local/thread';
|
|
import DatabaseManager from '@database/manager';
|
|
|
|
export async function handleThreadUpdatedEvent(serverUrl: string, msg: WebSocketMessage): Promise<void> {
|
|
try {
|
|
const thread = JSON.parse(msg.data.thread) as Thread;
|
|
const teamId = msg.broadcast.team_id;
|
|
|
|
// Mark it as following
|
|
thread.is_following = true;
|
|
processReceivedThreads(serverUrl, [thread], teamId, true);
|
|
} catch (error) {
|
|
// Do nothing
|
|
}
|
|
}
|
|
|
|
export async function handleThreadReadChangedEvent(serverUrl: string, msg: WebSocketMessage): Promise<void> {
|
|
const operator = DatabaseManager.serverDatabases[serverUrl].operator;
|
|
if (!operator) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
if (operator) {
|
|
const {thread_id, timestamp, unread_mentions, unread_replies} = msg.data as ThreadReadChangedData;
|
|
if (thread_id) {
|
|
await updateThread(serverUrl, thread_id, {
|
|
last_viewed_at: timestamp,
|
|
unread_mentions,
|
|
unread_replies,
|
|
});
|
|
} else {
|
|
await markTeamThreadsAsRead(serverUrl, msg.broadcast.team_id);
|
|
}
|
|
}
|
|
} catch (error) {
|
|
// Do nothing
|
|
}
|
|
}
|
|
|
|
export async function handleThreadFollowChangedEvent(serverUrl: string, msg: WebSocketMessage): Promise<void> {
|
|
const operator = DatabaseManager.serverDatabases[serverUrl].operator;
|
|
if (!operator) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
if (operator) {
|
|
const {reply_count, state, thread_id} = msg.data as {
|
|
reply_count: number;
|
|
state: boolean;
|
|
thread_id: string;
|
|
};
|
|
await updateThread(serverUrl, thread_id, {
|
|
is_following: state,
|
|
reply_count,
|
|
});
|
|
}
|
|
} catch (error) {
|
|
// Do nothing
|
|
}
|
|
}
|