[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:
parent
e34b7cbb87
commit
4def17c2e9
|
@ -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', {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue