forked from Ivasoft/mattermost-mobile
* Init * Test fix * New sync implementation * misc * Includes migration and other servers sync * Misc * Migration fix * Migration is done version 7 * Update app/queries/servers/thread.ts Co-authored-by: Elias Nahum <nahumhbl@gmail.com> * Update app/database/operator/server_data_operator/handlers/team_threads_sync.ts Co-authored-by: Elias Nahum <nahumhbl@gmail.com> * Feedback changes * Fixes when old thread gets a reply * Fix Co-authored-by: Mattermod <mattermod@users.noreply.github.com> Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
44 lines
1.6 KiB
TypeScript
44 lines
1.6 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {Relation} from '@nozbe/watermelondb';
|
|
import {field, immutableRelation} from '@nozbe/watermelondb/decorators';
|
|
import Model, {Associations} from '@nozbe/watermelondb/Model';
|
|
|
|
import {MM_TABLES} from '@constants/database';
|
|
|
|
import type TeamModel from '@typings/database/models/servers/team';
|
|
import type ThreadModel from '@typings/database/models/servers/thread';
|
|
import type ThreadInTeamModelInterface from '@typings/database/models/servers/thread_in_team';
|
|
|
|
const {TEAM, THREAD, THREADS_IN_TEAM} = MM_TABLES.SERVER;
|
|
|
|
/**
|
|
* ThreadInTeam model helps us to combine adjacent threads together without leaving
|
|
* gaps in between for an efficient user reading experience for threads.
|
|
*/
|
|
export default class ThreadInTeamModel extends Model implements ThreadInTeamModelInterface {
|
|
/** table (name) : ThreadsInTeam */
|
|
static table = THREADS_IN_TEAM;
|
|
|
|
/** associations : Describes every relationship to this table. */
|
|
static associations: Associations = {
|
|
|
|
/** A TEAM can have many THREADS_IN_TEAM. (relationship is N:1)*/
|
|
[TEAM]: {type: 'belongs_to', key: 'team_id'},
|
|
|
|
/** A THREAD can have many THREADS_IN_TEAM. (relationship is N:1)*/
|
|
[THREAD]: {type: 'belongs_to', key: 'thread_id'},
|
|
};
|
|
|
|
/** thread_id: Associated thread identifier */
|
|
@field('thread_id') threadId!: string;
|
|
|
|
/** team_id: Associated team identifier */
|
|
@field('team_id') teamId!: string;
|
|
|
|
@immutableRelation(THREAD, 'thread_id') thread!: Relation<ThreadModel>;
|
|
|
|
@immutableRelation(TEAM, 'team_id') team!: Relation<TeamModel>;
|
|
}
|