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>
36 lines
1.4 KiB
TypeScript
36 lines
1.4 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 TeamThreadsSyncModelInterface from '@typings/database/models/servers/team_threads_sync';
|
|
|
|
const {TEAM, TEAM_THREADS_SYNC} = MM_TABLES.SERVER;
|
|
|
|
/**
|
|
* ThreadInTeam model helps us to sync threads without creating any gaps between the threads
|
|
* by keeping track of the latest and earliest last_replied_at timestamps loaded for a team.
|
|
*/
|
|
export default class TeamThreadsSyncModel extends Model implements TeamThreadsSyncModelInterface {
|
|
/** table (name) : TeamThreadsSync */
|
|
static table = TEAM_THREADS_SYNC;
|
|
|
|
/** associations : Describes every relationship to this table. */
|
|
static associations: Associations = {
|
|
[TEAM]: {type: 'belongs_to', key: 'id'},
|
|
};
|
|
|
|
/** earliest: Oldest last_replied_at loaded through infinite loading */
|
|
@field('earliest') earliest!: number;
|
|
|
|
/** latest: Newest last_replied_at loaded during app init / navigating to global threads / pull to refresh */
|
|
@field('latest') latest!: number;
|
|
|
|
@immutableRelation(TEAM, 'id') team!: Relation<TeamModel>;
|
|
}
|