forked from Ivasoft/mattermost-mobile
MM-36721 - [GEKIDOU] Porting Markdown components (#5586)
* Started with Channel Post List * Added markdown hashtag * Added TouchableWithFeedback component * Added utils/bottom_sheet * Removed BottomSheet in favor of future SlideUpPanel * Added markdown_block_quote * Added markdown_list_item * Added markdown_list * Added MarkDownTableCell component * Markdown_table - in progress - need to verify TS * Added markdown_table * Update Podfile.lock * Added deep_linking constant * Added utils/draft * Update config to include ExperimentalNormalizeMarkdownLinks * Added markdown_link * Added markdown_table_row * Added ProgressiveImage and RetriableImage components and images utils * Converted Retriable component to functional component * Added type definition for commonmark * Continuing with markdown TS * Markdown - Typing props [ in progress ] * Fix boolean flag with mardown block quote * Adding observable config to markdown_link * TS Fixes [ in progress ] * TS fixes * TS fixes - TextStyles * Update markdown.tsx * TS fixes on markdown * TS Fixes - AtMention component * AtMention [ IN PROGRESS ] * Add markdown support * Fix emoji and jumboEmoji on iOS * Fix handleMyTeam operator * Fix navigation style based on theme * Fix iOS MattermostManaged deleteDatabse return error type * wrap setNavigationStackStyles under a requestAnimationFrame * Add preventDoubleTap to channel mention * Increase double tap to 750ms * Fix handleReceivedPostsInChannel chunk query * Set initial navigation theme * Swizzle FastImage on iOS * fix preventDoubleTap test Co-authored-by: Avinash Lingaloo <> Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
This commit is contained in:
@@ -142,6 +142,25 @@ describe('*** Operator: Channel Handlers tests ***', () => {
|
||||
expect.assertions(2);
|
||||
|
||||
const spyOnHandleRecords = jest.spyOn(operator, 'handleRecords');
|
||||
const channels: Channel[] = [{
|
||||
id: 'c',
|
||||
name: 'channel',
|
||||
display_name: 'Channel',
|
||||
type: 'O',
|
||||
create_at: 1,
|
||||
update_at: 1,
|
||||
delete_at: 0,
|
||||
team_id: '123',
|
||||
header: '',
|
||||
purpose: '',
|
||||
last_post_at: 2,
|
||||
creator_id: 'me',
|
||||
total_msg_count: 20,
|
||||
extra_update_at: 0,
|
||||
shared: false,
|
||||
scheme_id: null,
|
||||
group_constrained: false,
|
||||
}];
|
||||
const myChannels: ChannelMembership[] = [
|
||||
{
|
||||
id: 'c',
|
||||
@@ -164,6 +183,7 @@ describe('*** Operator: Channel Handlers tests ***', () => {
|
||||
];
|
||||
|
||||
await operator.handleMyChannel({
|
||||
channels,
|
||||
myChannels,
|
||||
prepareRecordsOnly: false,
|
||||
});
|
||||
|
||||
@@ -34,7 +34,7 @@ export interface ChannelHandlerMix {
|
||||
handleChannel: ({channels, prepareRecordsOnly}: HandleChannelArgs) => Promise<ChannelModel[]>;
|
||||
handleMyChannelSettings: ({settings, prepareRecordsOnly}: HandleMyChannelSettingsArgs) => Promise<MyChannelSettingsModel[]>;
|
||||
handleChannelInfo: ({channelInfos, prepareRecordsOnly}: HandleChannelInfoArgs) => Promise<ChannelInfoModel[]>;
|
||||
handleMyChannel: ({myChannels, prepareRecordsOnly}: HandleMyChannelArgs) => Promise<MyChannelModel[]>;
|
||||
handleMyChannel: ({channels, myChannels, prepareRecordsOnly}: HandleMyChannelArgs) => Promise<MyChannelModel[]>;
|
||||
}
|
||||
|
||||
const ChannelHandler = (superclass: any) => class extends superclass {
|
||||
@@ -130,13 +130,20 @@ const ChannelHandler = (superclass: any) => class extends superclass {
|
||||
* @throws DataOperatorException
|
||||
* @returns {Promise<MyChannelModel[]>}
|
||||
*/
|
||||
handleMyChannel = ({myChannels, prepareRecordsOnly = true}: HandleMyChannelArgs): Promise<MyChannelModel[]> => {
|
||||
handleMyChannel = ({channels, myChannels, prepareRecordsOnly = true}: HandleMyChannelArgs): Promise<MyChannelModel[]> => {
|
||||
if (!myChannels.length) {
|
||||
throw new DataOperatorException(
|
||||
'An empty "myChannels" array has been passed to the handleMyChannel method',
|
||||
);
|
||||
}
|
||||
|
||||
myChannels.forEach((my) => {
|
||||
const channel = channels.find((c) => c.id === my.channel_id);
|
||||
if (channel) {
|
||||
my.msg_count = Math.max(0, channel.total_msg_count - my.msg_count);
|
||||
}
|
||||
});
|
||||
|
||||
const createOrUpdateRawValues = getUniqueRawsBy({
|
||||
raws: myChannels,
|
||||
key: 'id',
|
||||
|
||||
@@ -74,12 +74,10 @@ const PostsInChannelHandler = (superclass: any) => class extends superclass {
|
||||
const latest = lastPost.create_at;
|
||||
|
||||
// Find the records in the PostsInChannel table that have a matching channel_id
|
||||
// const chunks = (await database.collections.get(POSTS_IN_CHANNEL).query(Q.where('channel_id', channelId)).fetch()) as PostsInChannel[];
|
||||
const chunks = (await retrieveRecords({
|
||||
database: this.database,
|
||||
tableName: POSTS_IN_CHANNEL,
|
||||
condition: (Q.where('id', channelId), Q.experimentalSortBy('latest', Q.desc)),
|
||||
})) as PostsInChannelModel[];
|
||||
const chunks = (await this.database.get(POSTS_IN_CHANNEL).query(
|
||||
Q.where('id', channelId),
|
||||
Q.experimentalSortBy('latest', Q.desc),
|
||||
).fetch()) as PostsInChannelModel[];
|
||||
|
||||
// chunk length 0; then it's a new chunk to be added to the PostsInChannel table
|
||||
if (chunks.length === 0) {
|
||||
|
||||
@@ -201,7 +201,7 @@ const TeamHandler = (superclass: any) => class extends superclass {
|
||||
);
|
||||
}
|
||||
|
||||
const createOrUpdateRawValues = getUniqueRawsBy({raws: myTeams, key: 'team_id'});
|
||||
const createOrUpdateRawValues = getUniqueRawsBy({raws: myTeams, key: 'id'});
|
||||
|
||||
return this.handleRecords({
|
||||
fieldName: 'id',
|
||||
|
||||
Reference in New Issue
Block a user