From bec1bc77c70342e131388e530ede17e935d29e76 Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Silva Date: Mon, 30 Oct 2023 17:41:29 -0300 Subject: [PATCH] fix: checks if the room exists before navigating to it (#5278) * checks if the room exists before navigating to it * Update app/i18n/locales/pt-BR.json Co-authored-by: Diego Mello --------- Co-authored-by: Diego Mello --- app/containers/markdown/Hashtag.tsx | 22 +++++++++++++++++----- app/i18n/locales/en.json | 2 ++ app/i18n/locales/pt-BR.json | 3 +++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/app/containers/markdown/Hashtag.tsx b/app/containers/markdown/Hashtag.tsx index 5cd50030b..0d92f3d18 100644 --- a/app/containers/markdown/Hashtag.tsx +++ b/app/containers/markdown/Hashtag.tsx @@ -1,13 +1,17 @@ import React from 'react'; import { StyleProp, Text, TextStyle } from 'react-native'; +import i18n from '../../i18n'; import { themes } from '../../lib/constants'; -import { useTheme } from '../../theme'; -import { IUserChannel } from './interfaces'; -import styles from './styles'; import { getSubscriptionByRoomId } from '../../lib/database/services/Subscription'; import { useAppSelector } from '../../lib/hooks'; +import { showErrorAlert } from '../../lib/methods/helpers'; import { goRoom } from '../../lib/methods/helpers/goRoom'; +import { Services } from '../../lib/services'; +import { useTheme } from '../../theme'; +import { sendLoadingEvent } from '../Loading'; +import { IUserChannel } from './interfaces'; +import styles from './styles'; interface IHashtag { hashtag: string; @@ -30,8 +34,16 @@ const Hashtag = React.memo(({ hashtag, channels, navToRoomInfo, style = [] }: IH const room = navParam.rid && (await getSubscriptionByRoomId(navParam.rid)); if (room) { goRoom({ item: room, isMasterDetail }); - } else { - navToRoomInfo(navParam); + } else if (navParam.rid) { + sendLoadingEvent({ visible: true }); + try { + await Services.getRoomInfo(navParam.rid); + sendLoadingEvent({ visible: false }); + navToRoomInfo(navParam); + } catch (error) { + sendLoadingEvent({ visible: false }); + showErrorAlert(i18n.t('The_room_does_not_exist'), i18n.t('Room_not_found')); + } } } }; diff --git a/app/i18n/locales/en.json b/app/i18n/locales/en.json index b839ff0aa..53528fb7a 100644 --- a/app/i18n/locales/en.json +++ b/app/i18n/locales/en.json @@ -750,6 +750,8 @@ "Continue": "Continue", "Message_has_been_shared": "Message has been shared", "No_channels_in_team": "No Channels on this team", + "Room_not_found": "Room not found", + "The_room_does_not_exist": "The room does not exist or you may not have access permission", "Supported_versions_expired_title": "{{workspace_name}} is running an unsupported version of Rocket.Chat", "Supported_versions_expired_description": "An admin needs to update the workspace to a supported version in order to reenable access from mobile and desktop apps.", "Supported_versions_warning_update_required": "Update required" diff --git a/app/i18n/locales/pt-BR.json b/app/i18n/locales/pt-BR.json index a3fd49242..a23c9ea13 100644 --- a/app/i18n/locales/pt-BR.json +++ b/app/i18n/locales/pt-BR.json @@ -736,6 +736,9 @@ "decline": "Recusar", "accept": "Aceitar", "Incoming_call_from": "Chamada recebida de", + "Call_started": "Chamada Iniciada", + "Room_not_found": "Sala não encontrada", + "The_room_does_not_exist": "A sala não existe ou você pode não ter permissão de acesso", "Call_started": "Chamada iniciada", "Supported_versions_expired_title": "{{workspace_name}} está executando uma versão não suportada do Rocket.Chat", "Supported_versions_expired_description": "Um administrador precisa atualizar o espaço de trabalho para uma versão suportada a fim de reabilitar o acesso a partir de aplicativos móveis e de desktop.",