* Add autotranslations * Develop latest changes and missing features * i18n-extract * Fix tests and update api behavior * Fix minor bugs * adjustments to shimmer animation, showtranslation modal style * Update post.tsx * Update show_translation.tsx * adjust sizing and opacity of translate icon * Add channel header translated icon * Disable auto translation item if it is not a supported language * Move channel info to the top * Update edit channel to channel info * Fix align of option items * Fix i18n * Add detox related changes for channel settings changes * Add tests * Address changes around the my channel column change * Address feedback * Fix test * Fix bad import * Fix set my channel autotranslation * Fix test * Address feedback * Add missing files from last commit * Remove unneeded change --------- Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>
49 lines
2.2 KiB
TypeScript
49 lines
2.2 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 {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 {getTimezone} from '@utils/user';
|
|
|
|
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;
|
|
} & WithDatabaseArgs;
|
|
|
|
const enhancedWithoutPosts = withObservables(['channelId'], ({database, channelId}: OwnProps) => {
|
|
const currentUser = observeCurrentUser(database);
|
|
const isChannelAutotranslated = observeIsChannelAutotranslated(database, channelId);
|
|
return {
|
|
appsEnabled: observeConfigBooleanValue(database, 'FeatureFlagAppsEnabled'),
|
|
currentTimezone: currentUser.pipe((switchMap((user) => of$(getTimezone(user?.timezone || null))))),
|
|
currentUserId: currentUser.pipe((switchMap((user) => of$(user?.id)))),
|
|
currentUsername: currentUser.pipe((switchMap((user) => of$(user?.username)))),
|
|
customEmojiNames: queryAllCustomEmojis(database).observeWithColumns(['name']).pipe(
|
|
switchMap((customEmojis) => of$(mapCustomEmojiNames(customEmojis))),
|
|
),
|
|
isPostAcknowledgementEnabled: observeIsPostAcknowledgementsEnabled(database),
|
|
isChannelAutotranslated,
|
|
};
|
|
});
|
|
|
|
const enhanced = withObservables(['posts'], ({database, posts}: {posts: PostModel[]} & WithDatabaseArgs) => {
|
|
const postIds = posts.map((p) => p.id);
|
|
return {
|
|
savedPostIds: observeSavedPostsByIds(database, postIds),
|
|
};
|
|
});
|
|
|
|
export default React.memo(withDatabase(enhancedWithoutPosts(enhanced(PostList))));
|