mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-05 18:38:54 +00:00
* Mattermost Blocks * Move block renderer to its own components folder * Sync translation layer * UX fixes * Refactor button to use the button component * Code review * Fix CI * Add animations to collapse blocks * Add unit tests * Add e2e tests and related fixes * Address coderabbit comments * Address UX comments * Address feedback * Address coderabbit comments * Fix snapshots * Sync with webapp translation * Add node limit to button markdown node * Address feedback * i18n-extract * Fix test * Move image utils to the utils folder * Remove unneeded style * Revert build script change --------- Co-authored-by: Mattermost Build <build@mattermost.com>
48 lines
2.1 KiB
TypeScript
48 lines
2.1 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {withDatabase, withObservables} from '@nozbe/watermelondb/react';
|
|
import React from 'react';
|
|
import {of as of$} from 'rxjs';
|
|
import {switchMap} from 'rxjs/operators';
|
|
|
|
import {withServerUrl} from '@context/server';
|
|
import {observeIsChannelAutotranslated} from '@queries/servers/channel';
|
|
import {queryAllCustomEmojis} from '@queries/servers/custom_emoji';
|
|
import {observeSavedPostsByIds, observeIsPostAcknowledgementsEnabled} from '@queries/servers/post';
|
|
import {observeConfigBooleanValue} from '@queries/servers/system';
|
|
import {observeCurrentUser} from '@queries/servers/user';
|
|
import {mapCustomEmojiNames} from '@utils/emoji/helpers';
|
|
|
|
import PostList from './post_list';
|
|
|
|
import type {WithDatabaseArgs} from '@typings/database/database';
|
|
import type PostModel from '@typings/database/models/servers/post';
|
|
|
|
type OwnProps = {
|
|
channelId: string;
|
|
serverUrl?: string;
|
|
} & WithDatabaseArgs;
|
|
|
|
const enhancedWithoutPosts = withObservables(['channelId'], ({database, channelId}: OwnProps) => {
|
|
return {
|
|
appsEnabled: observeConfigBooleanValue(database, 'FeatureFlagAppsEnabled'),
|
|
mmBlocksEnabled: observeConfigBooleanValue(database, 'FeatureFlagMmBlocksEnabled'),
|
|
currentUser: observeCurrentUser(database),
|
|
customEmojiNames: queryAllCustomEmojis(database).observeWithColumns(['name']).pipe(
|
|
switchMap((customEmojis) => of$(mapCustomEmojiNames(customEmojis))),
|
|
),
|
|
isPostAcknowledgementEnabled: observeIsPostAcknowledgementsEnabled(database),
|
|
isChannelAutotranslated: observeIsChannelAutotranslated(database, channelId),
|
|
};
|
|
});
|
|
|
|
const enhanced = withObservables(['posts', 'serverUrl'], ({database, posts, serverUrl}: {posts: PostModel[]; serverUrl?: string} & WithDatabaseArgs) => {
|
|
const postIds = posts.map((p) => p.id);
|
|
return {
|
|
savedPostIds: observeSavedPostsByIds(database, postIds, serverUrl),
|
|
};
|
|
});
|
|
|
|
export default React.memo(withDatabase(enhancedWithoutPosts(withServerUrl(enhanced(PostList)))));
|