fix: enables navigation for deleted threads (#5317)

* fix navigation to deleted thread

* fxi threads without name

* fix thread name
This commit is contained in:
Gleidson Daniel Silva 2023-11-28 14:17:47 -03:00 committed by GitHub
parent 16347b0bb6
commit 74e500a4bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -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",

View File

@ -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<IRoomViewProps, IRoomViewState> {
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<IRoomViewProps, IRoomViewState> {
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<IRoomViewProps, IRoomViewState> {
isThreadRoom={!!this.tmid}
isIgnored={this.isIgnored(item)}
previousItem={previousItem}
fetchThreadName={this.getThreadName}
fetchThreadName={this.fetchThreadName}
onReactionPress={this.onReactionPress}
onReactionLongPress={this.onReactionLongPress}
onLongPress={this.onMessageLongPress}