From 74e500a4bbeabf7ccc62f4e1945252e46e8e5e46 Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Silva Date: Tue, 28 Nov 2023 14:17:47 -0300 Subject: [PATCH] fix: enables navigation for deleted threads (#5317) * fix navigation to deleted thread * fxi threads without name * fix thread name --- app/i18n/locales/en.json | 1 + app/views/RoomView/index.tsx | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/i18n/locales/en.json b/app/i18n/locales/en.json index 076a9f737..2ad610f72 100644 --- a/app/i18n/locales/en.json +++ b/app/i18n/locales/en.json @@ -397,6 +397,7 @@ "This_room_is_blocked": "This room is blocked", "This_room_is_read_only": "This room is read only", "Threads": "Threads", + "Thread": "Thread", "Timezone": "Timezone", "topic": "topic", "Topic": "Topic", diff --git a/app/views/RoomView/index.tsx b/app/views/RoomView/index.tsx index 42b4f7cf6..9d1f98a96 100644 --- a/app/views/RoomView/index.tsx +++ b/app/views/RoomView/index.tsx @@ -94,6 +94,7 @@ import { withActionSheet, IActionSheetProvider } from '../../containers/ActionSh import { goRoom, TGoRoomItem } from '../../lib/methods/helpers/goRoom'; import audioPlayer from '../../lib/methods/audioPlayer'; import { IListContainerRef, TListRef } from './List/definitions'; +import { getThreadById } from '../../lib/database/services/Thread'; type TStateAttrsUpdate = keyof IRoomViewState; @@ -1128,6 +1129,15 @@ class RoomView extends React.Component { return getThreadName(rid, tmid, messageId); }; + fetchThreadName = async (tmid: string, messageId: string) => { + const { rid } = this.state.room; + const threadRecord = await getThreadById(tmid); + if (threadRecord?.t === 'rm') { + return I18n.t('Message_removed'); + } + return getThreadName(rid, tmid, messageId); + }; + toggleFollowThread = async (isFollowingThread: boolean, tmid?: string) => { try { const threadMessageId = tmid ?? this.tmid; @@ -1177,6 +1187,10 @@ class RoomView extends React.Component { jumpToMessageId = item.id; } sendLoadingEvent({ visible: true, onCancel: this.cancelJumpToMessage }); + const threadRecord = await getThreadById(item.tmid); + if (threadRecord?.t === 'rm') { + name = I18n.t('Thread'); + } if (!name) { const result = await this.getThreadName(item.tmid, jumpToMessageId); // test if there isn't a thread @@ -1335,7 +1349,7 @@ class RoomView extends React.Component { isThreadRoom={!!this.tmid} isIgnored={this.isIgnored(item)} previousItem={previousItem} - fetchThreadName={this.getThreadName} + fetchThreadName={this.fetchThreadName} onReactionPress={this.onReactionPress} onReactionLongPress={this.onReactionLongPress} onLongPress={this.onMessageLongPress}