Skip to content

Commit

Permalink
Add "mark as read" action
Browse files Browse the repository at this point in the history
  • Loading branch information
SpiritCroc committed Nov 17, 2021
1 parent 80667a6 commit d6ec5c4
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/components/views/rooms/RoomTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,23 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
this.setState({ generalMenuPosition: null }); // hide the menu
};

private onMarkReadClick = (ev: ButtonEvent) => {
ev.preventDefault();
ev.stopPropagation();
// Clear manually marked as unread
const markUnreadEnabled = SettingsStore.getValue("feature_mark_unread");
if (markUnreadEnabled) {
setRoomMarkedAsUnread(this.props.room, false);
}
// Update read receipt
const events = this.props.room.getLiveTimeline().getEvents();
if (events.length) {
// noinspection JSIgnoredPromiseFromCall
MatrixClientPeg.get().sendReadReceipt(events[events.length - 1]);
}
this.setState({ generalMenuPosition: null }); // hide the menu
};

private onTagRoom = (ev: ButtonEvent, tagId: TagID) => {
ev.preventDefault();
ev.stopPropagation();
Expand Down Expand Up @@ -512,6 +529,11 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
label={_t("Mark as unread")}
iconClassName="mx_RoomTile_markAsUnread"
/>) : null }
{(markUnreadEnabled && isUnread) ? (<IconizedContextMenuOption
onClick={this.onMarkReadClick}
label={_t("Mark as read")}
iconClassName="mx_RoomTile_markAsRead"
/>) : null }
<IconizedContextMenuCheckbox
onClick={(e) => this.onTagRoom(e, DefaultTagID.Favourite)}
active={isFavorite}
Expand Down

0 comments on commit d6ec5c4

Please sign in to comment.