fixes
This commit is contained in:
parent
b0becb4cee
commit
72d513987c
7 changed files with 42 additions and 37 deletions
|
|
@ -1264,7 +1264,7 @@ export const handleKickFromChannel = async (serverUrl: string, channelId: string
|
|||
}
|
||||
};
|
||||
|
||||
export const getGroupMessageMembersCommonTeams = async (serverUrl: string, channelId: string) => {
|
||||
export const fetchGroupMessageMembersCommonTeams = async (serverUrl: string, channelId: string) => {
|
||||
try {
|
||||
const client = NetworkManager.getClient(serverUrl);
|
||||
const teams = await client.getGroupMessageMembersCommonTeams(channelId);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ export const CHANNEL_FILES = 'ChannelFiles';
|
|||
export const CHANNEL_INFO = 'ChannelInfo';
|
||||
export const CHANNEL_NOTIFICATION_PREFERENCES = 'ChannelNotificationPreferences';
|
||||
export const CODE = 'Code';
|
||||
export const CONVERT_GM_TO_CHANNEL = 'ConvertGMToChannel';
|
||||
export const CREATE_DIRECT_MESSAGE = 'CreateDirectMessage';
|
||||
export const CREATE_OR_EDIT_CHANNEL = 'CreateOrEditChannel';
|
||||
export const CREATE_TEAM = 'CreateTeam';
|
||||
|
|
@ -65,13 +66,12 @@ export const SHARE_FEEDBACK = 'ShareFeedback';
|
|||
export const SNACK_BAR = 'SnackBar';
|
||||
export const SSO = 'SSO';
|
||||
export const TABLE = 'Table';
|
||||
export const TEAM_SELECTOR_LIST = 'TeamSelectorList';
|
||||
export const TERMS_OF_SERVICE = 'TermsOfService';
|
||||
export const THREAD = 'Thread';
|
||||
export const THREAD_FOLLOW_BUTTON = 'ThreadFollowButton';
|
||||
export const THREAD_OPTIONS = 'ThreadOptions';
|
||||
export const USER_PROFILE = 'UserProfile';
|
||||
export const CONVERT_GM_TO_CHANNEL = 'ConvertGMToChannel';
|
||||
export const TEAM_SELECTOR_LIST = 'TeamSelectorList';
|
||||
|
||||
export default {
|
||||
ABOUT,
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ export function observePermissionForTeam(database: Database, team: TeamModel | u
|
|||
return observeMyTeam(database, team.id).pipe(
|
||||
switchMap((myTeam) => {
|
||||
const rolesArray = [...user.roles.split(' ')];
|
||||
|
||||
if (myTeam) {
|
||||
rolesArray.push(...myTeam.roles.split(' '));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ import {Database, Q} from '@nozbe/watermelondb';
|
|||
import {of as of$, Observable, combineLatest} from 'rxjs';
|
||||
import {switchMap, distinctUntilChanged} from 'rxjs/operators';
|
||||
|
||||
import {logError} from '@app/utils/log';
|
||||
import {Preferences} from '@constants';
|
||||
import {MM_TABLES, SYSTEM_IDENTIFIERS} from '@constants/database';
|
||||
import {PUSH_PROXY_STATUS_UNKNOWN} from '@constants/push_proxy';
|
||||
import {isMinimumServerVersion} from '@utils/helpers';
|
||||
import {logError} from '@utils/log';
|
||||
|
||||
import type ServerDataOperator from '@database/operator/server_data_operator';
|
||||
import type ConfigModel from '@typings/database/models/servers/config';
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@
|
|||
import React, {useEffect, useRef, useState} from 'react';
|
||||
import {useIntl} from 'react-intl';
|
||||
|
||||
import {fetchChannelMemberships, getGroupMessageMembersCommonTeams} from '@actions/remote/channel';
|
||||
import Loading from '@app/components/loading';
|
||||
import {useTheme} from '@app/context/theme';
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from '@app/utils/theme';
|
||||
import {typography} from '@app/utils/typography';
|
||||
import {fetchChannelMemberships, fetchGroupMessageMembersCommonTeams} from '@actions/remote/channel';
|
||||
import {PER_PAGE_DEFAULT} from '@client/rest/constants';
|
||||
import Loading from '@components/loading';
|
||||
import {useServerUrl} from '@context/server';
|
||||
import {useTheme} from '@context/theme';
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme';
|
||||
import {typography} from '@utils/typography';
|
||||
|
||||
import ConvertGMToChannelForm from './convert_gm_to_channel_form';
|
||||
|
||||
|
|
@ -54,6 +54,13 @@ const getStyleFromTheme = makeStyleSheetFromTheme((theme: Theme) => {
|
|||
color: changeOpacity(theme.centerChannelColor, 0.56),
|
||||
...typography('Body', 300, 'SemiBold'),
|
||||
},
|
||||
container: {
|
||||
paddingVertical: 24,
|
||||
paddingHorizontal: 20,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: 24,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
|
|
@ -62,7 +69,7 @@ const ConvertGMToChannel = ({
|
|||
currentUserId,
|
||||
}: Props) => {
|
||||
const theme = useTheme();
|
||||
const style = getStyleFromTheme(theme);
|
||||
const styles = getStyleFromTheme(theme);
|
||||
|
||||
const {formatMessage} = useIntl();
|
||||
|
||||
|
|
@ -80,7 +87,7 @@ const ConvertGMToChannel = ({
|
|||
useEffect(() => {
|
||||
loadingAnimationTimeoutRef.current = setTimeout(() => setLoadingAnimationTimeout(true), loadingIndicatorTimeout);
|
||||
async function work() {
|
||||
const {teams} = await getGroupMessageMembersCommonTeams(serverUrl, channelId);
|
||||
const {teams} = await fetchGroupMessageMembersCommonTeams(serverUrl, channelId);
|
||||
if (!teams || !mounted.current) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -104,9 +111,13 @@ const ConvertGMToChannel = ({
|
|||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!currentUserId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const options: GetUsersOptions = {sort: 'admin', active: true, per_page: PER_PAGE_DEFAULT};
|
||||
fetchChannelMemberships(serverUrl, channelId, options, true).then(({users, members}) => {
|
||||
if (!mounted.current || !currentUserId) {
|
||||
if (!mounted.current) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -123,11 +134,11 @@ const ConvertGMToChannel = ({
|
|||
if (showLoader) {
|
||||
return (
|
||||
<Loading
|
||||
containerStyle={style.loadingContainer}
|
||||
containerStyle={styles.loadingContainer}
|
||||
size='large'
|
||||
color={theme.buttonBg}
|
||||
footerText={formatMessage({id: 'channel_info.convert_gm_to_channel.loading.footer', defaultMessage: 'Fetching details...'})}
|
||||
footerTextStyles={style.text}
|
||||
footerTextStyles={styles.text}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import React, {useCallback, useEffect, useMemo, useState} from 'react';
|
||||
import React, {useCallback, useMemo, useState} from 'react';
|
||||
import {useIntl} from 'react-intl';
|
||||
import {Text, View} from 'react-native';
|
||||
|
||||
import {convertGroupMessageToPrivateChannel, switchToChannelById} from '@actions/remote/channel';
|
||||
import Loading from '@app/components/loading';
|
||||
import {logError} from '@app/utils/log';
|
||||
import Button from '@components/button';
|
||||
import Loading from '@components/loading';
|
||||
import {useServerUrl} from '@context/server';
|
||||
import {useTheme} from '@context/theme';
|
||||
import {isErrorWithMessage} from '@utils/errors';
|
||||
import {logError} from '@utils/log';
|
||||
import {preventDoubleTap} from '@utils/tap';
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme';
|
||||
import {displayUsername} from '@utils/user';
|
||||
|
|
@ -60,23 +60,16 @@ export const ConvertGMToChannelForm = ({
|
|||
const theme = useTheme();
|
||||
const styles = getStyleFromTheme(theme);
|
||||
const serverUrl = useServerUrl();
|
||||
const intl = useIntl();
|
||||
const {formatList, formatMessage} = useIntl();
|
||||
|
||||
const [selectedTeam, setSelectedTeam] = useState<Team>();
|
||||
const [selectedTeam, setSelectedTeam] = useState<Team>(commonTeams[0]);
|
||||
const [newChannelName, setNewChannelName] = useState<string>('');
|
||||
const [errorMessage, setErrorMessage] = useState<string>('');
|
||||
const [conversionInProgress, setConversionInProgress] = useState(false); // LOL revert this default value back to false
|
||||
const [conversionInProgress, setConversionInProgress] = useState(false);
|
||||
|
||||
const {formatMessage} = useIntl();
|
||||
const userDisplayNames = useMemo(() => profiles.map((profile) => displayUsername(profile, locale, teammateNameDisplay)), [profiles]);
|
||||
const userDisplayNames = useMemo(() => profiles.map((profile) => displayUsername(profile, locale, teammateNameDisplay)), [profiles, teammateNameDisplay, locale]);
|
||||
const submitButtonEnabled = !conversionInProgress && selectedTeam && newChannelName.trim();
|
||||
|
||||
useEffect(() => {
|
||||
if (commonTeams.length > 0) {
|
||||
setSelectedTeam(commonTeams[0]);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const handleOnPress = useCallback(preventDoubleTap(async () => {
|
||||
if (!submitButtonEnabled) {
|
||||
return;
|
||||
|
|
@ -114,7 +107,7 @@ export const ConvertGMToChannelForm = ({
|
|||
);
|
||||
}
|
||||
|
||||
const messageBoxHeader = intl.formatMessage({
|
||||
const messageBoxHeader = formatMessage({
|
||||
id: 'channel_info.convert_gm_to_channel.warning.header',
|
||||
defaultMessage: 'Conversation history will be visible to any channel members',
|
||||
});
|
||||
|
|
@ -130,9 +123,9 @@ export const ConvertGMToChannelForm = ({
|
|||
});
|
||||
|
||||
const confirmButtonText = conversionInProgress ? textConverting : textConvert;
|
||||
const defaultUserDisplayNames = intl.formatMessage({id: 'channel_info.convert_gm_to_channel.warning.body.yourself', defaultMessage: 'yourself'});
|
||||
const memberNames = profiles.length > 0 ? intl.formatList(userDisplayNames) : defaultUserDisplayNames;
|
||||
const messageBoxBody = intl.formatMessage({
|
||||
const defaultUserDisplayNames = formatMessage({id: 'channel_info.convert_gm_to_channel.warning.body.yourself', defaultMessage: 'yourself'});
|
||||
const memberNames = profiles.length > 0 ? formatList(userDisplayNames) : defaultUserDisplayNames;
|
||||
const messageBoxBody = formatMessage({
|
||||
id: 'channel_info.convert_gm_to_channel.warning.bodyXXXX',
|
||||
defaultMessage: 'You are about to convert the Group Message with {memberNames} to a Channel. This cannot be undone.',
|
||||
}, {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import React, {useCallback} from 'react';
|
||||
import React from 'react';
|
||||
import {useIntl} from 'react-intl';
|
||||
import {View, type ViewStyle} from 'react-native';
|
||||
|
||||
|
|
@ -16,6 +16,10 @@ type Props = {
|
|||
containerStyles: ViewStyle;
|
||||
}
|
||||
|
||||
const handleOnPress = preventDoubleTap(() => {
|
||||
popTopScreen();
|
||||
});
|
||||
|
||||
export const NoCommonTeamForm = ({
|
||||
containerStyles,
|
||||
}: Props) => {
|
||||
|
|
@ -37,10 +41,6 @@ export const NoCommonTeamForm = ({
|
|||
defaultMessage: 'back',
|
||||
});
|
||||
|
||||
const handleOnPress = useCallback(preventDoubleTap(() => {
|
||||
popTopScreen();
|
||||
}), []);
|
||||
|
||||
return (
|
||||
<View style={containerStyles}>
|
||||
<MessageBox
|
||||
|
|
|
|||
Loading…
Reference in a new issue