* Add Create DM screen * Add channel toggle and minor improvements * Fix tests and apply new UI * Address feedback UX feedback and fix missing menu item by adding another item height * Add display name to channels and piggyback improvement on fetchUserByIds action and translations fix * Address feedback * Fix hardcoded colors Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
52 lines
2.2 KiB
TypeScript
52 lines
2.2 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {Q} from '@nozbe/watermelondb';
|
|
import {withDatabase} from '@nozbe/watermelondb/DatabaseProvider';
|
|
import withObservables from '@nozbe/with-observables';
|
|
import {combineLatest, of as of$} from 'rxjs';
|
|
import {map, switchMap} from 'rxjs/operators';
|
|
|
|
import {General, Preferences} from '@constants';
|
|
import {MM_TABLES, SYSTEM_IDENTIFIERS} from '@constants/database';
|
|
import {getTeammateNameDisplaySetting} from '@helpers/api/preference';
|
|
|
|
import CreateDirectMessage from './create_direct_message';
|
|
|
|
import type {WithDatabaseArgs} from '@typings/database/database';
|
|
import type PreferenceModel from '@typings/database/models/servers/preference';
|
|
import type SystemModel from '@typings/database/models/servers/system';
|
|
|
|
const {SERVER: {SYSTEM, PREFERENCE}} = MM_TABLES;
|
|
|
|
const enhanced = withObservables([], ({database}: WithDatabaseArgs) => {
|
|
const config = database.get<SystemModel>(SYSTEM).findAndObserve(SYSTEM_IDENTIFIERS.CONFIG);
|
|
const license = database.get<SystemModel>(SYSTEM).findAndObserve(SYSTEM_IDENTIFIERS.LICENSE);
|
|
const preferences = database.get<PreferenceModel>(PREFERENCE).query(Q.where('category', Preferences.CATEGORY_DISPLAY_SETTINGS)).observe();
|
|
const currentUserId = database.get<SystemModel>(SYSTEM).findAndObserve(SYSTEM_IDENTIFIERS.CURRENT_USER_ID).pipe(
|
|
switchMap(({value}) => of$(value)),
|
|
);
|
|
const currentTeamId = database.get<SystemModel>(SYSTEM).findAndObserve(SYSTEM_IDENTIFIERS.CURRENT_TEAM_ID).pipe(
|
|
switchMap(({value}) => of$(value)),
|
|
);
|
|
|
|
const teammateNameDisplay = combineLatest([config, license, preferences]).pipe(
|
|
map(
|
|
([{value: cfg}, {value: lcs}, prefs]) => getTeammateNameDisplaySetting(prefs, cfg, lcs),
|
|
),
|
|
);
|
|
|
|
const restrictDirectMessage = config.pipe(
|
|
switchMap(({value: cfg}) => of$(cfg.RestrictDirectMessage !== General.RESTRICT_DIRECT_MESSAGE_ANY)),
|
|
);
|
|
|
|
return {
|
|
teammateNameDisplay,
|
|
currentUserId,
|
|
restrictDirectMessage,
|
|
currentTeamId,
|
|
};
|
|
});
|
|
|
|
export default withDatabase(enhanced(CreateDirectMessage));
|
|
|