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