forked from Ivasoft/mattermost-mobile
[Gekidou HOTFIX] fixes saving threads in the DB (#6132)
* [Gekidou HOTFIX] fixes saving threads in the DB `loadedInGlobalThreads` cannot be a property of the thread, the DB will fail with unknown column upon saving. This commit makes it an argument of handleThreads and handleThreadInTeam. Fixes wrong foreignKey in THREAD table associations. * Fixes errors * Fixes error
This commit is contained in:
@@ -106,15 +106,23 @@ export default class TeamModel extends Model implements TeamModelInterface {
|
||||
@lazy threadsList = this.collections.get<ThreadModel>(THREAD).query(
|
||||
Q.on(THREADS_IN_TEAM, Q.and(
|
||||
Q.where('team_id', this.id),
|
||||
Q.where('loadedInGlobalThreads', true),
|
||||
Q.where('loaded_in_global_threads', true),
|
||||
)),
|
||||
Q.and(
|
||||
Q.where('reply_count', Q.gt(0)),
|
||||
Q.where('is_following', true),
|
||||
),
|
||||
Q.sortBy('last_reply_at', Q.desc),
|
||||
);
|
||||
|
||||
/** unreadThreadsList : Unread threads list belonging to a team */
|
||||
@lazy unreadThreadsList = this.collections.get<ThreadModel>(THREAD).query(
|
||||
Q.on(THREADS_IN_TEAM, 'team_id', this.id),
|
||||
Q.where('unread_replies', Q.gt(0)),
|
||||
Q.and(
|
||||
Q.where('reply_count', Q.gt(0)),
|
||||
Q.where('is_following', true),
|
||||
Q.where('unread_replies', Q.gt(0)),
|
||||
),
|
||||
Q.sortBy('last_reply_at', Q.desc),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ export default class ThreadModel extends Model implements ThreadModelInterface {
|
||||
[THREAD_PARTICIPANT]: {type: 'has_many', foreignKey: 'thread_id'},
|
||||
|
||||
/** A THREAD can have multiple THREADS_IN_TEAM. (relationship is 1:N)*/
|
||||
[THREADS_IN_TEAM]: {type: 'has_many', foreignKey: 'team_id'},
|
||||
[THREADS_IN_TEAM]: {type: 'has_many', foreignKey: 'thread_id'},
|
||||
};
|
||||
|
||||
/** last_reply_at : The timestamp of when user last replied to the thread. */
|
||||
|
||||
@@ -28,7 +28,7 @@ export default class ThreadInTeamModel extends Model implements ThreadInTeamMode
|
||||
[TEAM]: {type: 'belongs_to', key: 'team_id'},
|
||||
|
||||
/** A THREAD can have many THREADS_IN_TEAM. (relationship is N:1)*/
|
||||
[THREAD]: {type: 'belongs_to', key: 'team_id'},
|
||||
[THREAD]: {type: 'belongs_to', key: 'thread_id'},
|
||||
};
|
||||
|
||||
/** thread_id: Associated thread identifier */
|
||||
|
||||
Reference in New Issue
Block a user