Add Discussions to ThreadMessagesView
This commit is contained in:
parent
a0eecdcaf4
commit
659f2c8646
|
@ -688,6 +688,7 @@
|
|||
"No_threads": "There are no threads",
|
||||
"No_threads_following": "You are not following any threads",
|
||||
"No_threads_unread": "There are no unread threads",
|
||||
"No_discussions": "There are no discussions",
|
||||
"Messagebox_Send_to_channel": "Send to channel",
|
||||
"Leader": "Leader",
|
||||
"Moderator": "Moderator",
|
||||
|
|
|
@ -903,7 +903,7 @@ class RoomActionsView extends React.Component {
|
|||
room, membersCount, canViewMembers, canAddUser, canInviteUser, joined, canAutoTranslate, canForwardGuest, canReturnQueue
|
||||
} = this.state;
|
||||
const {
|
||||
rid, t
|
||||
rid, t, prid
|
||||
} = room;
|
||||
const isGroupChat = RocketChat.isGroupChat(room);
|
||||
|
||||
|
@ -974,14 +974,20 @@ class RoomActionsView extends React.Component {
|
|||
)
|
||||
: null}
|
||||
|
||||
{['c', 'p'].includes(t)
|
||||
{['c', 'p'].includes(t) && !prid
|
||||
? (
|
||||
<>
|
||||
<List.Item
|
||||
title='Discussions'
|
||||
onPress={() => this.onPressTouchable({
|
||||
route: 'ThreadMessagesView',
|
||||
params: { rid, t, name: 'Discussions' }
|
||||
params: {
|
||||
rid,
|
||||
t,
|
||||
prid,
|
||||
name: 'Discussions',
|
||||
isDiscussion: true
|
||||
}
|
||||
})}
|
||||
testID='room-actions-discussions'
|
||||
left={() => <List.Icon name='discussions' />}
|
||||
|
|
|
@ -55,6 +55,9 @@ class ThreadMessagesView extends React.Component {
|
|||
this.mounted = false;
|
||||
this.rid = props.route.params?.rid;
|
||||
this.t = props.route.params?.t;
|
||||
this.name = props.route.params?.name;
|
||||
this.isDiscussion = props.route.params?.isDiscussion;
|
||||
this.prid = props.route.params?.prid;
|
||||
this.state = {
|
||||
loading: false,
|
||||
end: false,
|
||||
|
@ -131,7 +134,7 @@ class ThreadMessagesView extends React.Component {
|
|||
/>
|
||||
),
|
||||
headerTitleAlign: 'center',
|
||||
headerTitle: I18n.t('Threads'),
|
||||
headerTitle: this.isDiscussion ? this.name : I18n.t('Threads'),
|
||||
headerTitleContainerStyle: {
|
||||
left: null,
|
||||
right: null
|
||||
|
@ -296,6 +299,18 @@ class ThreadMessagesView extends React.Component {
|
|||
|
||||
this.setState({ loading: true });
|
||||
|
||||
if (this.isDiscussion) {
|
||||
try {
|
||||
const db = database.active;
|
||||
const subCollection = db.get('subscriptions');
|
||||
const discussions = await subCollection.query(
|
||||
Q.where('prid', Q.eq(this.prid))
|
||||
);
|
||||
this.setState({ loading: false, displayingThreads: discussions });
|
||||
} catch (e) {
|
||||
log(e);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
const result = await RocketChat.getThreadsList({
|
||||
rid: this.rid, count: API_FETCH_COUNT, offset: messages.length, text: searchText
|
||||
|
@ -311,6 +326,7 @@ class ThreadMessagesView extends React.Component {
|
|||
log(e);
|
||||
this.setState({ loading: false, end: true });
|
||||
}
|
||||
}
|
||||
}, 300)
|
||||
|
||||
// eslint-disable-next-line react/sort-comp
|
||||
|
@ -434,7 +450,7 @@ class ThreadMessagesView extends React.Component {
|
|||
|
||||
renderHeader = () => {
|
||||
const { messages, currentFilter } = this.state;
|
||||
if (!messages.length) {
|
||||
if (!messages.length || this.isDiscussion) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -458,7 +474,7 @@ class ThreadMessagesView extends React.Component {
|
|||
} else if (currentFilter === FILTER.UNREAD) {
|
||||
text = I18n.t('No_threads_unread');
|
||||
} else {
|
||||
text = I18n.t('No_threads');
|
||||
text = this.isDiscussion ? I18n.t('No_discussions') : I18n.t('No_threads');
|
||||
}
|
||||
return (
|
||||
<>
|
||||
|
|
Loading…
Reference in New Issue