[Gekidou MM-41093] CRT - WS Events, Actions, Queries, Thread Follow, Post Query (#6075)

* WS Events, Actions, Queries, Thread Follow, Post Query

* i18n changes

* Misc

* Only unread threads are marked as read

* Mark threads from WS even as visible in Global threads

* Merge fixes

* Update thread_post_list.tsx

* Merge fix

* Feedback fix

* Make teamId in handleThreads optional for unfollowed threads

* Removed unwated type and return

* Review changes

* Removing unused model

* Merge fix

* Misc fixes

* Following button query change
This commit is contained in:
Anurag Shivarathri
2022-04-04 19:55:13 +05:30
committed by GitHub
parent d1322e84ce
commit 8d6fc41dd5
40 changed files with 1147 additions and 117 deletions

View File

@@ -24,7 +24,7 @@ const {
} = Database.MM_TABLES.SERVER;
export interface ThreadHandlerMix {
handleThreads: ({threads, prepareRecordsOnly}: HandleThreadsArgs) => Promise<Model[]>;
handleThreads: ({threads, teamId, prepareRecordsOnly}: HandleThreadsArgs) => Promise<Model[]>;
handleThreadParticipants: ({threadsParticipants, prepareRecordsOnly}: HandleThreadParticipantsArgs) => Promise<ThreadParticipantModel[]>;
}
@@ -79,11 +79,13 @@ const ThreadHandler = (superclass: any) => class extends superclass {
const threadParticipants = (await this.handleThreadParticipants({threadsParticipants, prepareRecordsOnly: true})) as ThreadParticipantModel[];
batch.push(...threadParticipants);
const threadsInTeam = await this.handleThreadInTeam({
threadsMap: {[teamId]: threads},
prepareRecordsOnly: true,
}) as ThreadInTeamModel[];
batch.push(...threadsInTeam);
if (teamId) {
const threadsInTeam = await this.handleThreadInTeam({
threadsMap: {[teamId]: threads},
prepareRecordsOnly: true,
}) as ThreadInTeamModel[];
batch.push(...threadsInTeam);
}
if (batch.length && !prepareRecordsOnly) {
await this.batchRecords(batch);
@@ -97,10 +99,11 @@ const ThreadHandler = (superclass: any) => class extends superclass {
* @param {HandleThreadParticipantsArgs} handleThreadParticipants
* @param {ParticipantsPerThread[]} handleThreadParticipants.threadsParticipants
* @param {boolean} handleThreadParticipants.prepareRecordsOnly
* @param {boolean} handleThreadParticipants.skipSync
* @throws DataOperatorException
* @returns {Promise<Array<ThreadParticipantModel>>}
*/
handleThreadParticipants = async ({threadsParticipants, prepareRecordsOnly}: HandleThreadParticipantsArgs): Promise<ThreadParticipantModel[]> => {
handleThreadParticipants = async ({threadsParticipants, prepareRecordsOnly, skipSync = false}: HandleThreadParticipantsArgs): Promise<ThreadParticipantModel[]> => {
const batchRecords: ThreadParticipantModel[] = [];
if (!threadsParticipants.length) {
@@ -119,6 +122,7 @@ const ThreadHandler = (superclass: any) => class extends superclass {
database: this.database,
thread_id,
rawParticipants: rawValues,
skipSync,
});
if (createParticipants?.length) {

View File

@@ -32,11 +32,12 @@ export const transformThreadRecord = ({action, database, value}: TransformerArgs
const fieldsMapper = (thread: ThreadModel) => {
thread._raw.id = isCreateAction ? (raw?.id ?? thread.id) : record.id;
thread.lastReplyAt = raw.last_reply_at;
thread.lastViewedAt = raw.last_viewed_at;
thread.lastViewedAt = raw.last_viewed_at ?? record?.lastViewedAt ?? 0;
thread.replyCount = raw.reply_count;
thread.isFollowing = raw.is_following ?? record?.isFollowing;
thread.unreadReplies = raw.unread_replies;
thread.unreadMentions = raw.unread_mentions;
thread.unreadReplies = raw.unread_replies ?? record?.lastViewedAt ?? 0;
thread.unreadMentions = raw.unread_mentions ?? record?.lastViewedAt ?? 0;
thread.viewedAt = record?.viewedAt || 0;
};
return prepareBaseRecord({