Skip to content

Commit

Permalink
fix: enables navigation for deleted threads (#5317)
Browse files Browse the repository at this point in the history
* fix navigation to deleted thread

* fxi threads without name

* fix thread name
  • Loading branch information
dnlsilva authored Nov 28, 2023
1 parent 16347b0 commit 74e500a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 15 additions & 1 deletion app/views/RoomView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit 74e500a

Please sign in to comment.