no need to pass in ChannelModel. already have the channelId. just add

the displayName as a prop
This commit is contained in:
Jason Frerich
2022-12-04 21:35:24 -06:00
parent 4c00e58c4c
commit 6e89d4458e
2 changed files with 9 additions and 6 deletions

View File

@@ -8,22 +8,20 @@ import {StyleProp, ViewStyle} from 'react-native';
import OptionBox from '@components/option_box';
import {Screens} from '@constants';
import {useTheme} from '@context/theme';
import {ChannelModel} from '@database/models/server';
import {dismissBottomSheet, goToScreen, showModal} from '@screens/navigation';
import {changeOpacity} from '@utils/theme';
type Props = {
channel: ChannelModel;
channelId: string;
containerStyle?: StyleProp<ViewStyle>;
displayName: string;
inModal?: boolean;
testID?: string;
}
const AddPeopleBox = ({channel, containerStyle, inModal, testID}: Props) => {
const AddPeopleBox = ({channelId, containerStyle, displayName, inModal, testID}: Props) => {
const intl = useIntl();
const theme = useTheme();
const channelId = channel.id;
const displayName = channel.displayName;
const onAddPeople = useCallback(async () => {
const title = intl.formatMessage({id: 'mobile.channel_add_people.title', defaultMessage: 'Add Members'});

View File

@@ -3,6 +3,8 @@
import {withDatabase} from '@nozbe/watermelondb/DatabaseProvider';
import withObservables from '@nozbe/with-observables';
import {of as of$} from 'rxjs';
import {switchMap} from 'rxjs/operators';
import {observeChannel} from '@queries/servers/channel';
@@ -15,8 +17,11 @@ type Props = WithDatabaseArgs & {
}
const enhanced = withObservables(['channelId'], ({channelId, database}: Props) => {
const channel = observeChannel(database, channelId);
const displayName = channel.pipe(switchMap((c) => of$(c?.displayName)));
return {
channel: observeChannel(database, channelId),
displayName,
};
});