Remove old changes from ThreadMessagesView

This commit is contained in:
Gerzon Z 2021-07-21 17:22:03 -04:00
parent 9ad45f067c
commit fc59b7426c
1 changed files with 15 additions and 31 deletions

View File

@ -55,9 +55,6 @@ 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,
@ -134,7 +131,7 @@ class ThreadMessagesView extends React.Component {
/> />
), ),
headerTitleAlign: 'center', headerTitleAlign: 'center',
headerTitle: this.isDiscussion ? this.name : I18n.t('Threads'), headerTitle: I18n.t('Threads'),
headerTitleContainerStyle: { headerTitleContainerStyle: {
left: null, left: null,
right: null right: null
@ -299,33 +296,20 @@ class ThreadMessagesView extends React.Component {
this.setState({ loading: true }); this.setState({ loading: true });
if (this.isDiscussion) { try {
try { const result = await RocketChat.getThreadsList({
const db = database.active; rid: this.rid, count: API_FETCH_COUNT, offset: messages.length, text: searchText
const subCollection = db.get('subscriptions'); });
const discussions = await subCollection.query( if (result.success) {
Q.where('prid', Q.eq(this.prid)) this.updateThreads({ update: result.threads, lastThreadSync });
); this.setState({
this.setState({ loading: false, displayingThreads: discussions }); loading: false,
} catch (e) { end: result.count < API_FETCH_COUNT
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)
@ -450,7 +434,7 @@ class ThreadMessagesView extends React.Component {
renderHeader = () => { renderHeader = () => {
const { messages, currentFilter } = this.state; const { messages, currentFilter } = this.state;
if (!messages.length || this.isDiscussion) { if (!messages.length) {
return null; return null;
} }
@ -474,7 +458,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 = this.isDiscussion ? I18n.t('No_discussions') : I18n.t('No_threads'); text = I18n.t('No_threads');
} }
return ( return (
<> <>