From 86a47e08324450a7e4d94ac2efb50ac82a0bbe7d Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Fri, 17 Jun 2022 14:52:25 -0400 Subject: [PATCH] Fetch post authors when fetching posts (#6400) --- app/actions/remote/post.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/app/actions/remote/post.ts b/app/actions/remote/post.ts index f5f1e28e1..026bff6ab 100644 --- a/app/actions/remote/post.ts +++ b/app/actions/remote/post.ts @@ -410,6 +410,16 @@ export async function fetchPosts(serverUrl: string, channelId: string, page = 0, actionType: ActionType.POSTS.RECEIVED_SINCE, prepareRecordsOnly: true, }); + + const {authors} = await fetchPostAuthors(serverUrl, result.posts, true); + if (authors?.length) { + const userModels = await operator.handleUsers({ + users: authors, + prepareRecordsOnly: true, + }); + models.push(...userModels); + } + if (isCRTEnabled) { const threadModels = await prepareThreadsFromReceivedPosts(operator, result.posts); if (threadModels?.length) { @@ -515,6 +525,16 @@ export async function fetchPostsSince(serverUrl: string, channelId: string, sinc actionType: ActionType.POSTS.RECEIVED_SINCE, prepareRecordsOnly: true, }); + + const {authors} = await fetchPostAuthors(serverUrl, result.posts, true); + if (authors?.length) { + const userModels = await operator.handleUsers({ + users: authors, + prepareRecordsOnly: true, + }); + models.push(...userModels); + } + if (isCRTEnabled) { const threadModels = await prepareThreadsFromReceivedPosts(operator, result.posts); if (threadModels?.length) { @@ -624,6 +644,16 @@ export async function fetchPostThread(serverUrl: string, postId: string, fetchOn actionType: ActionType.POSTS.RECEIVED_IN_THREAD, prepareRecordsOnly: true, }); + + const {authors} = await fetchPostAuthors(serverUrl, result.posts, true); + if (authors?.length) { + const userModels = await operator.handleUsers({ + users: authors, + prepareRecordsOnly: true, + }); + models.push(...userModels); + } + if (isCRTEnabled) { const threadModels = await prepareThreadsFromReceivedPosts(operator, result.posts); if (threadModels?.length) {