45 lines
1.8 KiB
TypeScript
45 lines
1.8 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 compose from 'lodash/fp/compose';
|
|
import {of as of$} from 'rxjs';
|
|
import {switchMap} from 'rxjs/operators';
|
|
|
|
import {queryChannelsById} from '@queries/servers/channel';
|
|
import {queryAllCustomEmojis} from '@queries/servers/custom_emoji';
|
|
import {observeCanDownloadFiles, observeEnableSecureFilePreview} from '@queries/servers/security';
|
|
import {observeConfigBooleanValue} from '@queries/servers/system';
|
|
import {observeCurrentUser} from '@queries/servers/user';
|
|
import {mapCustomEmojiNames} from '@utils/emoji/helpers';
|
|
import {getTimezone} from '@utils/user';
|
|
|
|
import Results from './results';
|
|
|
|
import type {WithDatabaseArgs} from '@typings/database/database';
|
|
|
|
type enhancedProps = WithDatabaseArgs & {
|
|
fileChannelIds: string[];
|
|
}
|
|
|
|
const enhance = withObservables(['fileChannelIds'], ({database, fileChannelIds}: enhancedProps) => {
|
|
const fileChannels = queryChannelsById(database, fileChannelIds).observeWithColumns(['displayName']);
|
|
const currentUser = observeCurrentUser(database);
|
|
|
|
return {
|
|
appsEnabled: observeConfigBooleanValue(database, 'FeatureFlagAppsEnabled'),
|
|
currentTimezone: currentUser.pipe((switchMap((user) => of$(getTimezone(user?.timezone))))),
|
|
customEmojiNames: queryAllCustomEmojis(database).observe().pipe(
|
|
switchMap((customEmojis) => of$(mapCustomEmojiNames(customEmojis))),
|
|
),
|
|
fileChannels,
|
|
canDownloadFiles: observeCanDownloadFiles(database),
|
|
enableSecureFilePreview: observeEnableSecureFilePreview(database),
|
|
publicLinkEnabled: observeConfigBooleanValue(database, 'EnablePublicLink'),
|
|
};
|
|
});
|
|
|
|
export default compose(
|
|
withDatabase,
|
|
enhance,
|
|
)(Results);
|