Alert the user to unread notifications in prior versions of rooms

Fixes https://github.com/vector-im/riot-web/issues/8161
This commit is contained in:
Travis Ralston 2019-03-26 19:22:24 -06:00
parent db834b315a
commit 04a9038a05
4 changed files with 64 additions and 2 deletions

View file

@ -1515,6 +1515,25 @@ module.exports = React.createClass({
}
},
_getOldRoom: function() {
const createEvent = this.state.room.currentState.getStateEvents("m.room.create", "");
if (!createEvent || !createEvent.getContent()['predecessor']) return null;
return MatrixClientPeg.get().getRoom(createEvent.getContent()['predecessor']['room_id']);
},
_getHiddenHighlightCount: function() {
const oldRoom = this._getOldRoom();
if (!oldRoom) return 0;
return oldRoom.getUnreadNotificationCount('highlight');
},
_onHiddenHighlightsClick: function() {
const oldRoom = this._getOldRoom();
if (!oldRoom) return;
dis.dispatch({action: "view_room", room_id: oldRoom.roomId});
},
render: function() {
const RoomHeader = sdk.getComponent('rooms.RoomHeader');
const MessageComposer = sdk.getComponent('rooms.MessageComposer');
@ -1673,6 +1692,8 @@ module.exports = React.createClass({
!MatrixClientPeg.get().getKeyBackupEnabled()
);
const hiddenHighlightCount = this._getHiddenHighlightCount();
let aux = null;
let hideCancel = false;
if (this.state.forwardingEvent !== null) {
@ -1713,6 +1734,15 @@ module.exports = React.createClass({
room={this.state.room}
/>
);
} else if (hiddenHighlightCount > 0) {
aux = (
<div className="mx_RoomView_auxPanel_hiddenHighlights" onClick={this._onHiddenHighlightsClick}>
{_t(
"You have %(count)s unread notifications in a prior version of this room.",
{count: hiddenHighlightCount},
)}
</div>
);
}
const auxPanel = (