forked from Ivasoft/mattermost-mobile
Update Dependencies and bug fixes (#7000)
* update dependencies * update dependencies * feedback review * update @mattermost/react-native-turbo-mailer
This commit is contained in:
@@ -8,7 +8,7 @@ import {
|
||||
transformCategoryChannelRecord,
|
||||
} from '@database/operator/server_data_operator/transformers/category';
|
||||
|
||||
import ServerDataOperator from '..';
|
||||
import type ServerDataOperator from '..';
|
||||
|
||||
describe('*** Operator: Category Handlers tests ***', () => {
|
||||
let operator: ServerDataOperator;
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
transformMyChannelSettingsRecord,
|
||||
} from '@database/operator/server_data_operator/transformers/channel';
|
||||
|
||||
import ServerDataOperator from '..';
|
||||
import type ServerDataOperator from '..';
|
||||
|
||||
describe('*** Operator: Channel Handlers tests ***', () => {
|
||||
let operator: ServerDataOperator;
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
transformGroupRecord,
|
||||
} from '@database/operator/server_data_operator/transformers/group';
|
||||
|
||||
import ServerDataOperator from '..';
|
||||
import type ServerDataOperator from '..';
|
||||
|
||||
describe('*** Operator: Group Handlers tests ***', () => {
|
||||
let operator: ServerDataOperator;
|
||||
|
||||
@@ -9,7 +9,7 @@ import {buildDraftKey} from '@database/operator/server_data_operator/comparators
|
||||
import {transformDraftRecord} from '@database/operator/server_data_operator/transformers/post';
|
||||
import {createPostsChain} from '@database/operator/utils/post';
|
||||
|
||||
import ServerDataOperator from '..';
|
||||
import type ServerDataOperator from '..';
|
||||
|
||||
Q.sortBy = jest.fn().mockImplementation((field) => {
|
||||
return Q.where(field, Q.gte(0));
|
||||
|
||||
@@ -6,6 +6,7 @@ import {Q} from '@nozbe/watermelondb';
|
||||
import {Database} from '@constants';
|
||||
import {getPostListEdges} from '@database//operator/utils/post';
|
||||
import {transformPostsInChannelRecord} from '@database/operator/server_data_operator/transformers/post';
|
||||
import {emptyFunction} from '@utils/general';
|
||||
import {logWarning} from '@utils/log';
|
||||
|
||||
import type PostsInChannelModel from '@typings/database/models/servers/posts_in_channel';
|
||||
@@ -42,7 +43,7 @@ const PostsInChannelHandler = (superclass: any) => class extends superclass {
|
||||
for (const chunk of existingChunks) {
|
||||
if (newChunk.earliest <= chunk.earliest && newChunk.latest >= chunk.latest) {
|
||||
if (!prepareRecordsOnly) {
|
||||
newChunk.prepareUpdate();
|
||||
newChunk.prepareUpdate(emptyFunction);
|
||||
}
|
||||
result.push(newChunk);
|
||||
result.push(chunk.prepareDestroyPermanently());
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import DatabaseManager from '@database/manager';
|
||||
import ServerDataOperator from '@database/operator/server_data_operator';
|
||||
|
||||
import type ServerDataOperator from '@database/operator/server_data_operator';
|
||||
|
||||
describe('*** Operator: User Handlers tests ***', () => {
|
||||
let operator: ServerDataOperator;
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
transformTeamSearchHistoryRecord,
|
||||
} from '@database/operator/server_data_operator/transformers/team';
|
||||
|
||||
import ServerDataOperator from '..';
|
||||
import type ServerDataOperator from '..';
|
||||
|
||||
describe('*** Operator: Team Handlers tests ***', () => {
|
||||
let operator: ServerDataOperator;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import DatabaseManager from '@database/manager';
|
||||
import {transformThreadRecord, transformThreadParticipantRecord, transformThreadInTeamRecord, transformTeamThreadsSyncRecord} from '@database/operator/server_data_operator/transformers/thread';
|
||||
|
||||
import ServerDataOperator from '..';
|
||||
import type ServerDataOperator from '..';
|
||||
|
||||
jest.mock('@database/operator/utils/thread', () => {
|
||||
return {
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {Q} from '@nozbe/watermelondb';
|
||||
import Model from '@nozbe/watermelondb/Model';
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
import {
|
||||
@@ -14,6 +13,7 @@ import {sanitizeThreadParticipants} from '@database/operator/utils/thread';
|
||||
import {logWarning} from '@utils/log';
|
||||
|
||||
import type Database from '@nozbe/watermelondb/Database';
|
||||
import type Model from '@nozbe/watermelondb/Model';
|
||||
import type {HandleThreadsArgs, HandleThreadParticipantsArgs} from '@typings/database/database';
|
||||
import type ThreadModel from '@typings/database/models/servers/thread';
|
||||
import type ThreadInTeamModel from '@typings/database/models/servers/thread_in_team';
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import DatabaseManager from '@database/manager';
|
||||
import ServerDataOperator from '@database/operator/server_data_operator';
|
||||
import {buildPreferenceKey} from '@database/operator/server_data_operator/comparators';
|
||||
import {
|
||||
transformPreferenceRecord,
|
||||
transformUserRecord,
|
||||
} from '@database/operator/server_data_operator/transformers/user';
|
||||
|
||||
import type ServerDataOperator from '@database/operator/server_data_operator';
|
||||
|
||||
describe('*** Operator: User Handlers tests ***', () => {
|
||||
let operator: ServerDataOperator;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ describe('*** CATEGORY Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords.collection.modelClass.name).toBe('CategoryModel');
|
||||
expect(preparedRecords.collection.table).toBe('Category');
|
||||
});
|
||||
|
||||
it('=> transformCategoryChannelRecord: should return an array of type CategoryChannelModel', async () => {
|
||||
@@ -58,6 +58,6 @@ describe('*** CATEGORY Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords.collection.modelClass.name).toBe('CategoryChannelModel');
|
||||
expect(preparedRecords.collection.table).toBe('CategoryChannel');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -46,7 +46,7 @@ describe('*** CHANNEL Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords.collection.modelClass.name).toBe('ChannelModel');
|
||||
expect(preparedRecords.collection.table).toBe('Channel');
|
||||
});
|
||||
|
||||
it('=> transformMyChannelSettingsRecord: should return an array of type MyChannelSettings', async () => {
|
||||
@@ -82,7 +82,7 @@ describe('*** CHANNEL Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords!.collection.modelClass.name).toBe('MyChannelSettingsModel');
|
||||
expect(preparedRecords!.collection.table).toBe('MyChannelSettings');
|
||||
});
|
||||
|
||||
it('=> transformChannelInfoRecord: should return an array of type ChannelInfo', async () => {
|
||||
@@ -109,7 +109,7 @@ describe('*** CHANNEL Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords!.collection.modelClass.name).toBe('ChannelInfoModel');
|
||||
expect(preparedRecords!.collection.table).toBe('ChannelInfo');
|
||||
});
|
||||
|
||||
it('=> transformMyChannelRecord: should return an array of type MyChannel', async () => {
|
||||
@@ -138,7 +138,7 @@ describe('*** CHANNEL Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords!.collection.modelClass.name).toBe('MyChannelModel');
|
||||
expect(preparedRecords!.collection.table).toBe('MyChannel');
|
||||
});
|
||||
|
||||
it('=> transformChannelMembershipRecord: should return an array of type ChannelMembership', async () => {
|
||||
@@ -174,6 +174,6 @@ describe('*** CHANNEL Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords!.collection.modelClass.name).toBe('ChannelMembershipModel');
|
||||
expect(preparedRecords!.collection.table).toBe('ChannelMembership');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@ describe('*** Role Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords!.collection.modelClass.name).toBe('RoleModel');
|
||||
expect(preparedRecords!.collection.table).toBe('Role');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -51,7 +51,7 @@ describe('*** System Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords!.collection.modelClass.name).toBe('SystemModel');
|
||||
expect(preparedRecords!.collection.table).toBe('System');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -79,7 +79,7 @@ describe('*** CustomEmoj Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords!.collection.modelClass.name).toBe('CustomEmojiModel');
|
||||
expect(preparedRecords!.collection.table).toBe('CustomEmoji');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -29,6 +29,6 @@ describe('*** GROUP Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords.collection.modelClass.name).toBe('GroupModel');
|
||||
expect(preparedRecords.collection.table).toBe('Group');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import Model from '@nozbe/watermelondb/Model';
|
||||
|
||||
import {OperationType} from '@constants/database';
|
||||
|
||||
import type {TransformerArgs} from '@typings/database/database';
|
||||
import type Model from '@nozbe/watermelondb/Model';
|
||||
import type {PrepareBaseRecordArgs} from '@typings/database/database';
|
||||
|
||||
/**
|
||||
* prepareBaseRecord: This is the last step for each operator and depending on the 'action', it will either prepare an
|
||||
@@ -15,7 +14,7 @@ import type {TransformerArgs} from '@typings/database/database';
|
||||
* @param {Database} operatorBase.database
|
||||
* @param {string} operatorBase.tableName
|
||||
* @param {RecordPair} operatorBase.value
|
||||
* @param {((TransformerArgs) => void)} operatorBase.generator
|
||||
* @param {((PrepareBaseRecordArgs) => void)} operatorBase.generator
|
||||
* @returns {Promise<Model>}
|
||||
*/
|
||||
export const prepareBaseRecord = async ({
|
||||
@@ -24,10 +23,10 @@ export const prepareBaseRecord = async ({
|
||||
tableName,
|
||||
value,
|
||||
fieldsMapper,
|
||||
}: TransformerArgs): Promise<Model> => {
|
||||
}: PrepareBaseRecordArgs): Promise<Model> => {
|
||||
if (action === OperationType.UPDATE) {
|
||||
const record = value.record as Model;
|
||||
return record.prepareUpdate(() => fieldsMapper!(record));
|
||||
return record.prepareUpdate(() => fieldsMapper(record));
|
||||
}
|
||||
|
||||
return database.collections.get(tableName!).prepareCreate(fieldsMapper);
|
||||
|
||||
@@ -48,7 +48,7 @@ describe('*** POST Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords!.collection.modelClass.name).toBe('PostModel');
|
||||
expect(preparedRecords!.collection.table).toBe('Post');
|
||||
});
|
||||
|
||||
it('=> transformPostInThreadRecord: should return an array of type PostsInThread', async () => {
|
||||
@@ -72,9 +72,7 @@ describe('*** POST Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords!.collection.modelClass.name).toBe(
|
||||
'PostsInThreadModel',
|
||||
);
|
||||
expect(preparedRecords!.collection.table).toBe('PostsInThread');
|
||||
});
|
||||
|
||||
it('=> transformFileRecord: should return an array of type File', async () => {
|
||||
@@ -107,7 +105,7 @@ describe('*** POST Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords!.collection.modelClass.name).toBe('FileModel');
|
||||
expect(preparedRecords!.collection.table).toBe('File');
|
||||
});
|
||||
|
||||
it('=> transformDraftRecord: should return an array of type Draft', async () => {
|
||||
@@ -132,7 +130,7 @@ describe('*** POST Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords!.collection.modelClass.name).toBe('DraftModel');
|
||||
expect(preparedRecords!.collection.table).toBe('Draft');
|
||||
});
|
||||
|
||||
it('=> transformPostsInChannelRecord: should return an array of type PostsInChannel', async () => {
|
||||
@@ -156,8 +154,6 @@ describe('*** POST Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords!.collection.modelClass.name).toBe(
|
||||
'PostsInChannelModel',
|
||||
);
|
||||
expect(preparedRecords!.collection.table).toBe('PostsInChannel');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -30,6 +30,6 @@ describe('*** REACTION Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords!.collection.modelClass.name).toBe('ReactionModel');
|
||||
expect(preparedRecords!.collection.table).toBe('Reaction');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('*** TEAM Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords!.collection.modelClass.name).toBe('MyTeamModel');
|
||||
expect(preparedRecords!.collection.table).toBe('MyTeam');
|
||||
});
|
||||
|
||||
it('=> transformTeamRecord: should return an array of type Team', async () => {
|
||||
@@ -67,7 +67,7 @@ describe('*** TEAM Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords!.collection.modelClass.name).toBe('TeamModel');
|
||||
expect(preparedRecords!.collection.table).toBe('Team');
|
||||
});
|
||||
|
||||
it('=> transformTeamChannelHistoryRecord: should return an array of type Team', async () => {
|
||||
@@ -89,7 +89,7 @@ describe('*** TEAM Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords!.collection.modelClass.name).toBe('TeamChannelHistoryModel');
|
||||
expect(preparedRecords!.collection.table).toBe('TeamChannelHistory');
|
||||
});
|
||||
|
||||
it('=> transformTeamSearchHistoryRecord: should return an array of type TeamSearchHistory', async () => {
|
||||
@@ -113,7 +113,7 @@ describe('*** TEAM Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords!.collection.modelClass.name).toBe('TeamSearchHistoryModel');
|
||||
expect(preparedRecords!.collection.table).toBe('TeamSearchHistory');
|
||||
});
|
||||
|
||||
it('=> transformTeamMembershipRecord: should return an array of type TeamMembership', async () => {
|
||||
@@ -141,6 +141,6 @@ describe('*** TEAM Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords!.collection.modelClass.name).toBe('TeamMembershipModel');
|
||||
expect(preparedRecords!.collection.table).toBe('TeamMembership');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -22,7 +22,7 @@ describe('*** USER Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords!.collection.modelClass.name).toBe('PreferenceModel');
|
||||
expect(preparedRecords!.collection.table).toBe('Preference');
|
||||
});
|
||||
|
||||
it('=> transformUserRecord: should return an array of type User', async () => {
|
||||
@@ -78,6 +78,6 @@ describe('*** USER Prepare Records Test ***', () => {
|
||||
});
|
||||
|
||||
expect(preparedRecords).toBeTruthy();
|
||||
expect(preparedRecords!.collection.modelClass.name).toBe('UserModel');
|
||||
expect(preparedRecords!.collection.table).toBe('User');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user