* update js dependencies * update react-native libraries * update watermelonDB * update RN to 0.72.7 * update fastlane * fix remove_markdown/at_mention import * update mattermost libraries * update fastlane deps * remove haptic-feedback patch * update okhttp to 4.12.0 and patch netinfo to accurately identify VPN connections * create ImaegStyles intersection type
50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {withObservables} from '@nozbe/watermelondb/react';
|
|
import {of as of$, switchMap, combineLatestWith} from 'rxjs';
|
|
|
|
import {observeServerDisplayName} from '@queries/app/servers';
|
|
import {observeChannel} from '@queries/servers/channel';
|
|
import {observeTeam, queryJoinedTeams} from '@queries/servers/team';
|
|
import {observeServerHasChannels} from '@share/queries';
|
|
|
|
import Options from './options';
|
|
|
|
import type {WithDatabaseArgs} from '@typings/database/database';
|
|
|
|
type Props = WithDatabaseArgs & {
|
|
serverUrl?: string;
|
|
channelId?: string;
|
|
}
|
|
|
|
const enhanced = withObservables(['database', 'channelId', 'serverUrl'], ({database, channelId, serverUrl}: Props) => {
|
|
const channel = observeChannel(database, channelId || '');
|
|
const teamsCount = queryJoinedTeams(database).observeCount();
|
|
const team = channel.pipe(
|
|
switchMap((c) => (c?.teamId ? observeTeam(database, c.teamId) : of$(undefined))),
|
|
);
|
|
|
|
const channelDisplayName = channel.pipe(
|
|
combineLatestWith(team, teamsCount),
|
|
switchMap(([c, t, count]) => {
|
|
if (!c) {
|
|
return of$(undefined);
|
|
}
|
|
|
|
if (t) {
|
|
return of$(count > 1 ? `${c.displayName} (${t.displayName})` : c.displayName);
|
|
}
|
|
|
|
return of$(c.displayName);
|
|
}),
|
|
);
|
|
|
|
return {
|
|
channelDisplayName,
|
|
serverDisplayName: observeServerDisplayName(serverUrl || ''),
|
|
hasChannels: observeServerHasChannels(serverUrl || ''),
|
|
};
|
|
});
|
|
|
|
export default enhanced(Options);
|