forked from Ivasoft/mattermost-mobile
[Gekidou] Allow multiple posts in thread and posts in channel for a specific root or channel (#5594)
* Allow multiple posts in thread and posts in channel for a specific root or channel * Apply suggestions from code review Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com> Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com>
This commit is contained in:
@@ -75,7 +75,7 @@ const PostsInChannelHandler = (superclass: any) => class extends superclass {
|
||||
|
||||
// Find the records in the PostsInChannel table that have a matching channel_id
|
||||
const chunks = (await this.database.get(POSTS_IN_CHANNEL).query(
|
||||
Q.where('id', channelId),
|
||||
Q.where('channel_id', channelId),
|
||||
Q.experimentalSortBy('latest', Q.desc),
|
||||
).fetch()) as PostsInChannelModel[];
|
||||
|
||||
|
||||
@@ -32,13 +32,13 @@ const PostsInThreadHandler = (superclass: any) => class extends superclass {
|
||||
const chunks = (await retrieveRecords({
|
||||
database: this.database,
|
||||
tableName: POSTS_IN_THREAD,
|
||||
condition: Q.where('id', rootId),
|
||||
condition: Q.where('root_id', rootId),
|
||||
})) as PostsInThreadModel[];
|
||||
|
||||
if (chunks.length) {
|
||||
const chunk = chunks[0];
|
||||
const newValue = {
|
||||
id: rootId,
|
||||
root_id: rootId,
|
||||
earliest: Math.min(chunk.earliest, firstPost.create_at),
|
||||
latest: Math.max(chunk.latest, lastPost.create_at),
|
||||
};
|
||||
@@ -50,7 +50,7 @@ const PostsInThreadHandler = (superclass: any) => class extends superclass {
|
||||
} else {
|
||||
// create chunk
|
||||
create.push({
|
||||
id: rootId,
|
||||
root_id: rootId,
|
||||
earliest: firstPost.create_at,
|
||||
latest: lastPost.create_at,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user