Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMPROVEMENT] Mark thread as read on open #2225

Merged
merged 4 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/lib/rocketchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down
13 changes: 13 additions & 0 deletions app/views/RoomView/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class List extends React.Component {
} else {
this.state.messages = messages;
}
this.readThreads();
});
}
}
Expand All @@ -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;
Expand Down