From 805c794b3eb643b88c88ae87d04f75ca64450326 Mon Sep 17 00:00:00 2001 From: Tanmay Vardhaman Thole <72058456+tanmaythole@users.noreply.github.com> Date: Tue, 14 Nov 2023 14:30:19 +0530 Subject: [PATCH 1/4] MM 45015 - auto follow threads (#7463) * auto follow select option added * unused code removed * auto follow threads condition fixed on CRT enabled * error handles --------- Co-authored-by: Mattermost Build --- app/constants/channel.ts | 4 ++ app/screens/channel_info/channel_info.tsx | 3 + app/screens/channel_info/index.ts | 2 + .../auto_follow_threads.tsx | 61 +++++++++++++++++++ .../options/auto_follow_threads/index.ts | 35 +++++++++++ .../ignore_mentions/ignore_mentions.tsx | 27 ++++++-- .../options/ignore_mentions/index.ts | 4 +- app/screens/channel_info/options/index.tsx | 14 ++++- assets/base/i18n/en.json | 1 + types/api/channels.d.ts | 1 + 10 files changed, 142 insertions(+), 10 deletions(-) create mode 100644 app/screens/channel_info/options/auto_follow_threads/auto_follow_threads.tsx create mode 100644 app/screens/channel_info/options/auto_follow_threads/index.ts diff --git a/app/constants/channel.ts b/app/constants/channel.ts index 2c94cb3e9..8169187a7 100644 --- a/app/constants/channel.ts +++ b/app/constants/channel.ts @@ -6,6 +6,8 @@ export const MAX_CHANNEL_NAME_LENGTH = 64; export const IGNORE_CHANNEL_MENTIONS_ON = 'on'; export const IGNORE_CHANNEL_MENTIONS_OFF = 'off'; export const IGNORE_CHANNEL_MENTIONS_DEFAULT = 'default'; +export const CHANNEL_AUTO_FOLLOW_THREADS_TRUE = 'on'; +export const CHANNEL_AUTO_FOLLOW_THREADS_FALSE = 'off'; export default { IGNORE_CHANNEL_MENTIONS_ON, @@ -13,4 +15,6 @@ export default { IGNORE_CHANNEL_MENTIONS_DEFAULT, MAX_CHANNEL_NAME_LENGTH, MIN_CHANNEL_NAME_LENGTH, + CHANNEL_AUTO_FOLLOW_THREADS_TRUE, + CHANNEL_AUTO_FOLLOW_THREADS_FALSE, }; diff --git a/app/screens/channel_info/channel_info.tsx b/app/screens/channel_info/channel_info.tsx index 63292e136..8298427b9 100644 --- a/app/screens/channel_info/channel_info.tsx +++ b/app/screens/channel_info/channel_info.tsx @@ -30,6 +30,7 @@ type Props = { canEnableDisableCalls: boolean; isCallsEnabledInChannel: boolean; canManageMembers: boolean; + isCRTEnabled: boolean; canManageSettings: boolean; } @@ -51,6 +52,7 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({ })); const ChannelInfo = ({ + isCRTEnabled, channelId, closeButtonId, componentId, @@ -105,6 +107,7 @@ const ChannelInfo = ({ type={type} callsEnabled={callsAvailable} canManageMembers={canManageMembers} + isCRTEnabled={isCRTEnabled} canManageSettings={canManageSettings} /> diff --git a/app/screens/channel_info/index.ts b/app/screens/channel_info/index.ts index 3cdbd799f..acff1488a 100644 --- a/app/screens/channel_info/index.ts +++ b/app/screens/channel_info/index.ts @@ -17,6 +17,7 @@ import { observeCurrentTeamId, observeCurrentUserId, } from '@queries/servers/system'; +import {observeIsCRTEnabled} from '@queries/servers/thread'; import {observeCurrentUser, observeUserIsChannelAdmin, observeUserIsTeamAdmin} from '@queries/servers/user'; import {isTypeDMorGM} from '@utils/channel'; import {isMinimumServerVersion} from '@utils/helpers'; @@ -117,6 +118,7 @@ const enhanced = withObservables([], ({serverUrl, database}: Props) => { canEnableDisableCalls, isCallsEnabledInChannel, canManageMembers, + isCRTEnabled: observeIsCRTEnabled(database), canManageSettings, }; }); diff --git a/app/screens/channel_info/options/auto_follow_threads/auto_follow_threads.tsx b/app/screens/channel_info/options/auto_follow_threads/auto_follow_threads.tsx new file mode 100644 index 000000000..5421b1ff7 --- /dev/null +++ b/app/screens/channel_info/options/auto_follow_threads/auto_follow_threads.tsx @@ -0,0 +1,61 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import React, {useState} from 'react'; +import {useIntl} from 'react-intl'; + +import {updateChannelNotifyProps} from '@actions/remote/channel'; +import OptionItem from '@components/option_item'; +import { + CHANNEL_AUTO_FOLLOW_THREADS_FALSE, + CHANNEL_AUTO_FOLLOW_THREADS_TRUE, +} from '@constants/channel'; +import {useServerUrl} from '@context/server'; +import {t} from '@i18n'; +import {alertErrorWithFallback} from '@utils/draft'; +import {preventDoubleTap} from '@utils/tap'; + +type Props = { + channelId: string; + followedStatus: boolean; + displayName: string; +}; + +const AutoFollowThreads = ({channelId, displayName, followedStatus}: Props) => { + const [autoFollow, setAutoFollow] = useState(followedStatus); + const serverUrl = useServerUrl(); + const intl = useIntl(); + + const toggleFollow = preventDoubleTap(async () => { + const props: Partial = { + channel_auto_follow_threads: followedStatus ? CHANNEL_AUTO_FOLLOW_THREADS_FALSE : CHANNEL_AUTO_FOLLOW_THREADS_TRUE, + }; + setAutoFollow((v) => !v); + const result = await updateChannelNotifyProps(serverUrl, channelId, props); + if (result?.error) { + alertErrorWithFallback( + intl, + result.error, + { + id: t('channel_info.channel_auto_follow_threads_failed'), + defaultMessage: 'An error occurred trying to auto follow all threads in channel {displayName}', + }, + {displayName}, + ); + setAutoFollow((v) => !v); + } + }); + + return ( + + ); +}; + +export default AutoFollowThreads; diff --git a/app/screens/channel_info/options/auto_follow_threads/index.ts b/app/screens/channel_info/options/auto_follow_threads/index.ts new file mode 100644 index 000000000..f2a7a993a --- /dev/null +++ b/app/screens/channel_info/options/auto_follow_threads/index.ts @@ -0,0 +1,35 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import {withDatabase} from '@nozbe/watermelondb/DatabaseProvider'; +import withObservables from '@nozbe/with-observables'; +import {of as of$} from 'rxjs'; +import {switchMap} from 'rxjs/operators'; + +import {Channel} from '@constants'; +import {observeChannel, observeChannelSettings} from '@queries/servers/channel'; + +import AutoFollowThreads from './auto_follow_threads'; + +import type {WithDatabaseArgs} from '@typings/database/database'; + +type Props = WithDatabaseArgs & { + channelId: string; +} + +const enhanced = withObservables(['channelId'], ({channelId, database}: Props) => { + const channel = observeChannel(database, channelId); + const settings = observeChannelSettings(database, channelId); + const followedStatus = settings.pipe( + switchMap((s) => { + return of$(s?.notifyProps?.channel_auto_follow_threads === Channel.CHANNEL_AUTO_FOLLOW_THREADS_TRUE); + }), + ); + + return { + followedStatus, + displayName: channel.pipe(switchMap((c) => of$(c?.displayName))), + }; +}); + +export default withDatabase(enhanced(AutoFollowThreads)); diff --git a/app/screens/channel_info/options/ignore_mentions/ignore_mentions.tsx b/app/screens/channel_info/options/ignore_mentions/ignore_mentions.tsx index 2fef6479b..a9f0aaa97 100644 --- a/app/screens/channel_info/options/ignore_mentions/ignore_mentions.tsx +++ b/app/screens/channel_info/options/ignore_mentions/ignore_mentions.tsx @@ -5,6 +5,8 @@ import React, {useState} from 'react'; import {useIntl} from 'react-intl'; import {updateChannelNotifyProps} from '@actions/remote/channel'; +import {t} from '@app/i18n'; +import {alertErrorWithFallback} from '@app/utils/draft'; import OptionItem from '@components/option_item'; import {useServerUrl} from '@context/server'; import {preventDoubleTap} from '@utils/tap'; @@ -12,25 +14,38 @@ import {preventDoubleTap} from '@utils/tap'; type Props = { channelId: string; ignoring: boolean; + displayName: string; } -const IgnoreMentions = ({channelId, ignoring}: Props) => { +const IgnoreMentions = ({channelId, ignoring, displayName}: Props) => { const [ignored, setIgnored] = useState(ignoring); const serverUrl = useServerUrl(); - const {formatMessage} = useIntl(); + const intl = useIntl(); - const toggleIgnore = preventDoubleTap(() => { + const toggleIgnore = preventDoubleTap(async () => { const props: Partial = { ignore_channel_mentions: ignoring ? 'off' : 'on', }; - setIgnored(!ignored); - updateChannelNotifyProps(serverUrl, channelId, props); + setIgnored((v) => !v); + const result = await updateChannelNotifyProps(serverUrl, channelId, props); + if (result?.error) { + alertErrorWithFallback( + intl, + result.error, + { + id: t('channel_info.channel_auto_follow_threads_failed'), + defaultMessage: 'An error occurred trying to auto follow all threads in channel {displayName}', + }, + {displayName}, + ); + setIgnored((v) => !v); + } }); return ( { + const channel = observeChannel(database, channelId); const currentUser = observeCurrentUser(database); const settings = observeChannelSettings(database, channelId); const ignoring = currentUser.pipe( @@ -43,6 +44,7 @@ const enhanced = withObservables(['channelId'], ({channelId, database}: Props) = return { ignoring, + displayName: channel.pipe(switchMap((c) => of$(c?.displayName))), }; }); diff --git a/app/screens/channel_info/options/index.tsx b/app/screens/channel_info/options/index.tsx index 816fc2867..ed1837574 100644 --- a/app/screens/channel_info/options/index.tsx +++ b/app/screens/channel_info/options/index.tsx @@ -8,6 +8,7 @@ import {General} from '@constants'; import {isTypeDMorGM} from '@utils/channel'; import AddMembers from './add_members'; +import AutoFollowThreads from './auto_follow_threads'; import ChannelFiles from './channel_files'; import EditChannel from './edit_channel'; import IgnoreMentions from './ignore_mentions'; @@ -20,6 +21,7 @@ type Props = { type?: ChannelType; callsEnabled: boolean; canManageMembers: boolean; + isCRTEnabled: boolean; canManageSettings: boolean; } @@ -28,15 +30,21 @@ const Options = ({ type, callsEnabled, canManageMembers, + isCRTEnabled, canManageSettings, }: Props) => { const isDMorGM = isTypeDMorGM(type); return ( <> - {type !== General.DM_CHANNEL && - - } + {type !== General.DM_CHANNEL && ( + <> + {isCRTEnabled && ( + + )} + + + )} diff --git a/assets/base/i18n/en.json b/assets/base/i18n/en.json index e1be78279..9a184d37a 100644 --- a/assets/base/i18n/en.json +++ b/assets/base/i18n/en.json @@ -112,6 +112,7 @@ "channel_info.archive_description.cannot_view_archived": "This will archive the channel from the team and remove it from the user interface. Archived channels can be unarchived if needed again.\n\nAre you sure you wish to archive the {term} {name}?", "channel_info.archive_failed": "An error occurred trying to archive the channel {displayName}", "channel_info.archive_title": "Archive {term}", + "channel_info.channel_auto_follow_threads": "Follow all threads in this channel", "channel_info.channel_files": "Files", "channel_info.close": "Close", "channel_info.close_dm": "Close direct message", diff --git a/types/api/channels.d.ts b/types/api/channels.d.ts index ef0f2a659..b176b15f0 100644 --- a/types/api/channels.d.ts +++ b/types/api/channels.d.ts @@ -17,6 +17,7 @@ type ChannelNotifyProps = { mark_unread: 'all' | 'mention'; push: NotificationLevel; ignore_channel_mentions: 'default' | 'off' | 'on'; + channel_auto_follow_threads: 'on' | 'off'; push_threads: 'all' | 'mention'; }; type Channel = { From 94a910303bd932f026022c4038dcd26155dc3459 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Tue, 14 Nov 2023 19:14:46 +0800 Subject: [PATCH 2/4] Allow connecting to a previous server if credentials are not in the keychain (#7661) --- app/screens/server/index.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/screens/server/index.tsx b/app/screens/server/index.tsx index da8944214..dd9339b7b 100644 --- a/app/screens/server/index.tsx +++ b/app/screens/server/index.tsx @@ -17,6 +17,7 @@ import AppVersion from '@components/app_version'; import {Screens, Launch} from '@constants'; import useNavButtonPressed from '@hooks/navigation_button_pressed'; import {t} from '@i18n'; +import {getServerCredentials} from '@init/credentials'; import PushNotifications from '@init/push_notifications'; import NetworkManager from '@managers/network_manager'; import {getServerByDisplayName, getServerByIdentifier} from '@queries/app/servers'; @@ -244,7 +245,8 @@ const Server = ({ } const server = await getServerByDisplayName(displayName); - if (server && server.lastActiveAt > 0) { + const credentials = await getServerCredentials(serverUrl); + if (server && server.lastActiveAt > 0 && credentials?.token) { setButtonDisabled(true); setDisplayNameError(formatMessage({ id: 'mobile.server_name.exists', @@ -330,9 +332,10 @@ const Server = ({ } const server = await getServerByIdentifier(data.config.DiagnosticId); + const credentials = await getServerCredentials(serverUrl); setConnecting(false); - if (server && server.lastActiveAt > 0) { + if (server && server.lastActiveAt > 0 && credentials?.token) { setButtonDisabled(true); setUrlError(formatMessage({ id: 'mobile.server_identifier.exists', From f0334d8c0e6b1ef62ca1f59d2ba1e7ec9c9074f1 Mon Sep 17 00:00:00 2001 From: Christopher Poile Date: Tue, 14 Nov 2023 17:03:55 -0500 Subject: [PATCH 3/4] MM-54323 - Calls: Incoming call from different server (#7646) * refactor; tried to clarify more_messages; new design * adjust more_messages text spacing * small fix for height with incoming call on current channel * move calls-specific code in the calls product behind a hook * show servername for notifications from other servers * if >1 active servers, always show server name, otherwise don't * add height of notification bar in measurements --------- Co-authored-by: Mattermost Build --- .../call_notification/call_notification.tsx | 44 ++++++++++++++++--- .../components/call_notification/index.ts | 2 + app/products/calls/hooks.ts | 34 +++++++++++--- 3 files changed, 68 insertions(+), 12 deletions(-) diff --git a/app/products/calls/components/call_notification/call_notification.tsx b/app/products/calls/components/call_notification/call_notification.tsx index 40fa401ac..046461bd4 100644 --- a/app/products/calls/components/call_notification/call_notification.tsx +++ b/app/products/calls/components/call_notification/call_notification.tsx @@ -1,7 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import React, {useCallback, useEffect} from 'react'; +import React, {useCallback, useEffect, useState} from 'react'; import {useIntl} from 'react-intl'; import {Pressable, Text, View} from 'react-native'; @@ -18,11 +18,14 @@ import {useServerUrl} from '@context/server'; import {useTheme} from '@context/theme'; import DatabaseManager from '@database/manager'; import WebsocketManager from '@managers/websocket_manager'; +import {getServerDisplayName} from '@queries/app/servers'; import ChannelMembershipModel from '@typings/database/models/servers/channel_membership'; import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme'; import {typography} from '@utils/typography'; import {displayUsername} from '@utils/user'; +import type ServersModel from '@typings/database/models/app/servers'; + const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({ outerContainer: { borderRadius: 8, @@ -39,6 +42,9 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({ shadowRadius: 4, elevation: 4, }, + outerContainerServerName: { + height: CALL_NOTIFICATION_BAR_HEIGHT + 8, + }, innerContainer: { flexDirection: 'row', width: '100%', @@ -71,6 +77,7 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({ }, textContainer: { flex: 1, + flexDirection: 'column', marginLeft: 8, }, text: { @@ -81,6 +88,11 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({ ...typography('Body', 100, 'SemiBold'), lineHeight: 20, }, + textServerName: { + ...typography('Heading', 25), + color: changeOpacity(theme.buttonColor, 0.72), + textTransform: 'uppercase', + }, dismissContainer: { alignItems: 'center', width: 32, @@ -93,6 +105,7 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({ })); type Props = { + servers: ServersModel[]; incomingCall: IncomingCallNotification; currentUserId: string; teammateNameDisplay: string; @@ -101,6 +114,7 @@ type Props = { } export const CallNotification = ({ + servers, incomingCall, currentUserId, teammateNameDisplay, @@ -111,6 +125,8 @@ export const CallNotification = ({ const serverUrl = useServerUrl(); const theme = useTheme(); const style = getStyleSheet(theme); + const [serverName, setServerName] = useState(''); + const moreThanOneServer = servers.length > 1; useEffect(() => { const channelMembers = members?.filter((m) => m.userId !== currentUserId); @@ -119,13 +135,24 @@ export const CallNotification = ({ } }, []); + // We only need to getServerDisplayName once + useEffect(() => { + async function getName() { + setServerName(await getServerDisplayName(incomingCall.serverUrl)); + } + + if (moreThanOneServer) { + getName(); + } + }, [moreThanOneServer, incomingCall.serverUrl]); + const onContainerPress = useCallback(async () => { - if (serverUrl !== incomingCall.serverUrl) { + if (incomingCall.serverUrl !== serverUrl) { await DatabaseManager.setActiveServerDatabase(incomingCall.serverUrl); await WebsocketManager.initializeClient(incomingCall.serverUrl); } switchToChannelById(incomingCall.serverUrl, incomingCall.channelID); - }, [serverUrl, incomingCall]); + }, [incomingCall, serverUrl]); const onDismissPress = useCallback(() => { removeIncomingCall(serverUrl, incomingCall.callID, incomingCall.channelID); @@ -143,7 +170,7 @@ export const CallNotification = ({ name: displayUsername(incomingCall.callerModel, intl.locale, teammateNameDisplay), }} style={style.text} - numberOfLines={2} + numberOfLines={1} ellipsizeMode={'tail'} /> ); @@ -158,14 +185,14 @@ export const CallNotification = ({ num: (members?.length || 2) - 1, }} style={style.text} - numberOfLines={2} + numberOfLines={1} ellipsizeMode={'tail'} /> ); } return ( - + {message} + {moreThanOneServer && + + {serverName} + + } diff --git a/app/products/calls/components/call_notification/index.ts b/app/products/calls/components/call_notification/index.ts index 7e7c807f8..ff0dfc6f2 100644 --- a/app/products/calls/components/call_notification/index.ts +++ b/app/products/calls/components/call_notification/index.ts @@ -5,6 +5,7 @@ import withObservables from '@nozbe/with-observables'; import {of as of$} from 'rxjs'; import {distinctUntilChanged, switchMap} from 'rxjs/operators'; +import {observeAllActiveServers} from '@app/queries/app/servers'; import {CallNotification} from '@calls/components/call_notification/call_notification'; import DatabaseManager from '@database/manager'; import {observeChannelMembers} from '@queries/servers/channel'; @@ -33,6 +34,7 @@ const enhanced = withObservables(['incomingCall'], ({incomingCall}: OwnProps) => ); return { + servers: observeAllActiveServers(), currentUserId, teammateNameDisplay, members, diff --git a/app/products/calls/hooks.ts b/app/products/calls/hooks.ts index 28d0fe35a..28a4aaf4f 100644 --- a/app/products/calls/hooks.ts +++ b/app/products/calls/hooks.ts @@ -8,13 +8,26 @@ import {useIntl} from 'react-intl'; import {Alert, Platform} from 'react-native'; import Permissions from 'react-native-permissions'; -import {CALL_ERROR_BAR_HEIGHT, CALL_NOTIFICATION_BAR_HEIGHT, CURRENT_CALL_BAR_HEIGHT, JOIN_CALL_BAR_HEIGHT} from '@app/constants/view'; +import { + CALL_ERROR_BAR_HEIGHT, + CALL_NOTIFICATION_BAR_HEIGHT, + CURRENT_CALL_BAR_HEIGHT, + JOIN_CALL_BAR_HEIGHT, +} from '@app/constants/view'; import {initializeVoiceTrack} from '@calls/actions/calls'; -import {setMicPermissionsGranted, useCallsState, useChannelsWithCalls, useCurrentCall, useGlobalCallsState, useIncomingCalls} from '@calls/state'; +import { + setMicPermissionsGranted, + useCallsState, + useChannelsWithCalls, + useCurrentCall, + useGlobalCallsState, + useIncomingCalls, +} from '@calls/state'; import {errorAlert} from '@calls/utils'; import {useServerUrl} from '@context/server'; import {useAppState} from '@hooks/device'; import NetworkManager from '@managers/network_manager'; +import {queryAllActiveServers} from '@queries/app/servers'; import {getFullErrorMessage} from '@utils/errors'; import type {Client} from '@client/rest'; @@ -110,26 +123,35 @@ export const usePermissionsChecker = (micPermissionsGranted: boolean) => { }, [appState]); }; -export const useCallsAdjustment = (serverUrl: string, channelId: string) => { +export const useCallsAdjustment = (serverUrl: string, channelId: string): number => { const incomingCalls = useIncomingCalls().incomingCalls; const channelsWithCalls = useChannelsWithCalls(serverUrl); const callsState = useCallsState(serverUrl); const globalCallsState = useGlobalCallsState(); const currentCall = useCurrentCall(); + const [numServers, setNumServers] = useState(1); const dismissed = Boolean(callsState.calls[channelId]?.dismissed[callsState.myUserId]); const inCurrentCall = currentCall?.id === channelId; const joinCallBannerVisible = Boolean(channelsWithCalls[channelId]) && !dismissed && !inCurrentCall; + useEffect(() => { + const getNumServers = async () => { + const query = await queryAllActiveServers()?.fetch(); + setNumServers(query?.length || 0); + }; + getNumServers(); + }, []); + // Do we have calls banners? const currentCallBarVisible = Boolean(currentCall); const micPermissionsError = !globalCallsState.micPermissionsGranted && (currentCall && !currentCall.micPermissionsErrorDismissed); const callQualityAlert = Boolean(currentCall?.callQualityAlert); const incomingCallsShowing = incomingCalls.filter((ic) => ic.channelID !== channelId); - const callsIncomingAdjustment = (incomingCallsShowing.length * CALL_NOTIFICATION_BAR_HEIGHT) + (incomingCallsShowing.length * 8); - const callsAdjustment = (currentCallBarVisible ? CURRENT_CALL_BAR_HEIGHT + 8 : 0) + + const notificationBarHeight = CALL_NOTIFICATION_BAR_HEIGHT + (numServers > 1 ? 8 : 0); + const callsIncomingAdjustment = (incomingCallsShowing.length * notificationBarHeight) + (incomingCallsShowing.length * 8); + return (currentCallBarVisible ? CURRENT_CALL_BAR_HEIGHT + 8 : 0) + (micPermissionsError ? CALL_ERROR_BAR_HEIGHT + 8 : 0) + (callQualityAlert ? CALL_ERROR_BAR_HEIGHT + 8 : 0) + (joinCallBannerVisible ? JOIN_CALL_BAR_HEIGHT + 8 : 0) + callsIncomingAdjustment; - return callsAdjustment; }; From 94e1334ebbd89ca3e5cc3caa3dbddcfbb8623d95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Espino=20Garc=C3=ADa?= Date: Wed, 15 Nov 2023 15:07:00 +0100 Subject: [PATCH 4/4] Maintenance fixes (#7665) --- .../post_list/more_messages/more_messages.tsx | 2 +- app/products/calls/hooks.ts | 12 ++++++------ .../auto_follow_threads/auto_follow_threads.tsx | 9 ++++----- .../options/ignore_mentions/ignore_mentions.tsx | 11 +++++------ assets/base/i18n/en.json | 1 + package-lock.json | 12 ++++++------ package.json | 2 +- 7 files changed, 24 insertions(+), 25 deletions(-) diff --git a/app/components/post_list/more_messages/more_messages.tsx b/app/components/post_list/more_messages/more_messages.tsx index bb33275b4..8b431a490 100644 --- a/app/components/post_list/more_messages/more_messages.tsx +++ b/app/components/post_list/more_messages/more_messages.tsx @@ -7,7 +7,7 @@ import Animated, {interpolate, useAnimatedStyle, useSharedValue, withSpring} fro import {useSafeAreaInsets} from 'react-native-safe-area-context'; import {resetMessageCount} from '@actions/local/channel'; -import {useCallsAdjustment} from '@app/products/calls/hooks'; +import {useCallsAdjustment} from '@calls/hooks'; import CompassIcon from '@components/compass_icon'; import FormattedText from '@components/formatted_text'; import TouchableWithFeedback from '@components/touchable_with_feedback'; diff --git a/app/products/calls/hooks.ts b/app/products/calls/hooks.ts index 28a4aaf4f..c319912a9 100644 --- a/app/products/calls/hooks.ts +++ b/app/products/calls/hooks.ts @@ -8,12 +8,6 @@ import {useIntl} from 'react-intl'; import {Alert, Platform} from 'react-native'; import Permissions from 'react-native-permissions'; -import { - CALL_ERROR_BAR_HEIGHT, - CALL_NOTIFICATION_BAR_HEIGHT, - CURRENT_CALL_BAR_HEIGHT, - JOIN_CALL_BAR_HEIGHT, -} from '@app/constants/view'; import {initializeVoiceTrack} from '@calls/actions/calls'; import { setMicPermissionsGranted, @@ -24,6 +18,12 @@ import { useIncomingCalls, } from '@calls/state'; import {errorAlert} from '@calls/utils'; +import { + CALL_ERROR_BAR_HEIGHT, + CALL_NOTIFICATION_BAR_HEIGHT, + CURRENT_CALL_BAR_HEIGHT, + JOIN_CALL_BAR_HEIGHT, +} from '@constants/view'; import {useServerUrl} from '@context/server'; import {useAppState} from '@hooks/device'; import NetworkManager from '@managers/network_manager'; diff --git a/app/screens/channel_info/options/auto_follow_threads/auto_follow_threads.tsx b/app/screens/channel_info/options/auto_follow_threads/auto_follow_threads.tsx index 5421b1ff7..9fe228750 100644 --- a/app/screens/channel_info/options/auto_follow_threads/auto_follow_threads.tsx +++ b/app/screens/channel_info/options/auto_follow_threads/auto_follow_threads.tsx @@ -2,7 +2,7 @@ // See LICENSE.txt for license information. import React, {useState} from 'react'; -import {useIntl} from 'react-intl'; +import {defineMessage, useIntl} from 'react-intl'; import {updateChannelNotifyProps} from '@actions/remote/channel'; import OptionItem from '@components/option_item'; @@ -11,7 +11,6 @@ import { CHANNEL_AUTO_FOLLOW_THREADS_TRUE, } from '@constants/channel'; import {useServerUrl} from '@context/server'; -import {t} from '@i18n'; import {alertErrorWithFallback} from '@utils/draft'; import {preventDoubleTap} from '@utils/tap'; @@ -36,10 +35,10 @@ const AutoFollowThreads = ({channelId, displayName, followedStatus}: Props) => { alertErrorWithFallback( intl, result.error, - { - id: t('channel_info.channel_auto_follow_threads_failed'), + defineMessage({ + id: 'channel_info.channel_auto_follow_threads_failed', defaultMessage: 'An error occurred trying to auto follow all threads in channel {displayName}', - }, + }), {displayName}, ); setAutoFollow((v) => !v); diff --git a/app/screens/channel_info/options/ignore_mentions/ignore_mentions.tsx b/app/screens/channel_info/options/ignore_mentions/ignore_mentions.tsx index a9f0aaa97..999eda54f 100644 --- a/app/screens/channel_info/options/ignore_mentions/ignore_mentions.tsx +++ b/app/screens/channel_info/options/ignore_mentions/ignore_mentions.tsx @@ -2,13 +2,12 @@ // See LICENSE.txt for license information. import React, {useState} from 'react'; -import {useIntl} from 'react-intl'; +import {defineMessage, useIntl} from 'react-intl'; import {updateChannelNotifyProps} from '@actions/remote/channel'; -import {t} from '@app/i18n'; -import {alertErrorWithFallback} from '@app/utils/draft'; import OptionItem from '@components/option_item'; import {useServerUrl} from '@context/server'; +import {alertErrorWithFallback} from '@utils/draft'; import {preventDoubleTap} from '@utils/tap'; type Props = { @@ -32,10 +31,10 @@ const IgnoreMentions = ({channelId, ignoring, displayName}: Props) => { alertErrorWithFallback( intl, result.error, - { - id: t('channel_info.channel_auto_follow_threads_failed'), + defineMessage({ + id: 'channel_info.channel_auto_follow_threads_failed', defaultMessage: 'An error occurred trying to auto follow all threads in channel {displayName}', - }, + }), {displayName}, ); setIgnored((v) => !v); diff --git a/assets/base/i18n/en.json b/assets/base/i18n/en.json index 9a184d37a..4aff99bae 100644 --- a/assets/base/i18n/en.json +++ b/assets/base/i18n/en.json @@ -113,6 +113,7 @@ "channel_info.archive_failed": "An error occurred trying to archive the channel {displayName}", "channel_info.archive_title": "Archive {term}", "channel_info.channel_auto_follow_threads": "Follow all threads in this channel", + "channel_info.channel_auto_follow_threads_failed": "An error occurred trying to auto follow all threads in channel {displayName}", "channel_info.channel_files": "Files", "channel_info.close": "Close", "channel_info.close_dm": "Close direct message", diff --git a/package-lock.json b/package-lock.json index dc6e5a2af..4fd0a6d6b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -164,7 +164,7 @@ "jest-cli": "29.6.2", "jetifier": "2.0.0", "metro-react-native-babel-preset": "0.77.0", - "mmjstool": "github:mattermost/mattermost-utilities#e65ab00f22628cbdee736fd2e4f192f07225e82d", + "mmjstool": "github:mattermost/mattermost-utilities#83b1b311972b8f5e750aae4019457a40abb5aa44", "mock-async-storage": "2.2.0", "nock": "13.3.2", "patch-package": "8.0.0", @@ -17436,8 +17436,8 @@ }, "node_modules/mmjstool": { "version": "1.0.0", - "resolved": "git+ssh://git@github.com/mattermost/mattermost-utilities.git#e65ab00f22628cbdee736fd2e4f192f07225e82d", - "integrity": "sha512-tY5XH26LwPztivGSbUWWaxZCkp/cKWTrtWBUnG8L1J+QIcLua8hzyZBe+VGDGdoHUJn4PbGpawJlUyoiC3r9Lg==", + "resolved": "git+ssh://git@github.com/mattermost/mattermost-utilities.git#83b1b311972b8f5e750aae4019457a40abb5aa44", + "integrity": "sha512-SFAbT+eN1mvgSfRTe8k6IMKVWbhGItTJtxZ+Pt0mX+fe8pakB3MkIkWzHBHVnEDI9Ek9kmQFGF1aZwzKFHXyYQ==", "dev": true, "dependencies": { "estree-walk": "^2.2.0", @@ -35806,10 +35806,10 @@ } }, "mmjstool": { - "version": "git+ssh://git@github.com/mattermost/mattermost-utilities.git#e65ab00f22628cbdee736fd2e4f192f07225e82d", - "integrity": "sha512-tY5XH26LwPztivGSbUWWaxZCkp/cKWTrtWBUnG8L1J+QIcLua8hzyZBe+VGDGdoHUJn4PbGpawJlUyoiC3r9Lg==", + "version": "git+ssh://git@github.com/mattermost/mattermost-utilities.git#83b1b311972b8f5e750aae4019457a40abb5aa44", + "integrity": "sha512-SFAbT+eN1mvgSfRTe8k6IMKVWbhGItTJtxZ+Pt0mX+fe8pakB3MkIkWzHBHVnEDI9Ek9kmQFGF1aZwzKFHXyYQ==", "dev": true, - "from": "mmjstool@github:mattermost/mattermost-utilities#e65ab00f22628cbdee736fd2e4f192f07225e82d", + "from": "mmjstool@github:mattermost/mattermost-utilities#83b1b311972b8f5e750aae4019457a40abb5aa44", "requires": { "estree-walk": "^2.2.0", "filehound": "^1.17.5", diff --git a/package.json b/package.json index 2590a3e11..2a0c0b9ff 100644 --- a/package.json +++ b/package.json @@ -165,7 +165,7 @@ "jest-cli": "29.6.2", "jetifier": "2.0.0", "metro-react-native-babel-preset": "0.77.0", - "mmjstool": "github:mattermost/mattermost-utilities#e65ab00f22628cbdee736fd2e4f192f07225e82d", + "mmjstool": "github:mattermost/mattermost-utilities#83b1b311972b8f5e750aae4019457a40abb5aa44", "mock-async-storage": "2.2.0", "nock": "13.3.2", "patch-package": "8.0.0",