[IMPROVEMENT] Mark thread as read on open (#2225)

* [IMPROVEMENT] Mark a thread as read

* Use methodCallWrapper

* Check server version

Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Djorkaeff Alexandre 2020-06-29 15:47:48 -03:00 committed by GitHub
parent e34b7cbb87
commit 4def17c2e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -1141,6 +1141,14 @@ const RocketChat = {
rid, updatedSince
});
},
readThreads(tmid) {
const serverVersion = reduxStore.getState().server.version;
if (serverVersion && semver.gte(semver.coerce(serverVersion), '3.4.0')) {
// RC 3.4.0
return this.methodCallWrapper('readThreads', tmid);
}
return Promise.resolve();
},
runSlashCommand(command, roomId, params, triggerId, tmid) {
// RC 0.60.2
return this.post('commands.run', {

View File

@ -115,6 +115,7 @@ class List extends React.Component {
} else {
this.state.messages = messages;
}
this.readThreads();
});
}
}
@ -125,6 +126,18 @@ class List extends React.Component {
this.init();
}
readThreads = async() => {
const { tmid } = this.props;
if (tmid) {
try {
await RocketChat.readThreads(tmid);
} catch {
// Do nothing
}
}
}
shouldComponentUpdate(nextProps, nextState) {
const { loading, end, refreshing } = this.state;
const { hideSystemMessages, theme } = this.props;