Merge pull request #2831 from matrix-org/travis/hidden-bing
Alert the user to unread notifications in prior versions of rooms
This commit is contained in:
commit
64a6b47692
4 changed files with 66 additions and 2 deletions
|
@ -70,6 +70,13 @@ limitations under the License.
|
||||||
background-color: $primary-bg-color;
|
background-color: $primary-bg-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mx_RoomView_auxPanel_hiddenHighlights {
|
||||||
|
border-bottom: 1px solid $primary-hairline-color;
|
||||||
|
padding: 10px 26px;
|
||||||
|
color: $warning-color;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.mx_RoomView_auxPanel_apps {
|
.mx_RoomView_auxPanel_apps {
|
||||||
max-width: 1920px ! important;
|
max-width: 1920px ! important;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import { Group } from 'matrix-js-sdk';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import RoomTile from "../views/rooms/RoomTile";
|
import RoomTile from "../views/rooms/RoomTile";
|
||||||
import LazyRenderList from "../views/elements/LazyRenderList";
|
import LazyRenderList from "../views/elements/LazyRenderList";
|
||||||
|
import MatrixClientPeg from "../../MatrixClientPeg";
|
||||||
|
|
||||||
// turn this on for drop & drag console debugging galore
|
// turn this on for drop & drag console debugging galore
|
||||||
const debug = false;
|
const debug = false;
|
||||||
|
@ -138,6 +139,28 @@ const RoomSubList = React.createClass({
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getUnreadNotificationCount: function(room, type=null) {
|
||||||
|
let notificationCount = room.getUnreadNotificationCount(type);
|
||||||
|
|
||||||
|
// Check notification counts in the old room just in case there's some lost
|
||||||
|
// there. We only go one level down to avoid performance issues, and theory
|
||||||
|
// is that 1st generation rooms will have already been read by the 3rd generation.
|
||||||
|
const createEvent = room.currentState.getStateEvents("m.room.create", "");
|
||||||
|
if (createEvent && createEvent.getContent()['predecessor']) {
|
||||||
|
const oldRoomId = createEvent.getContent()['predecessor']['room_id'];
|
||||||
|
const oldRoom = MatrixClientPeg.get().getRoom(oldRoomId);
|
||||||
|
if (oldRoom) {
|
||||||
|
// We only ever care if there's highlights in the old room. No point in
|
||||||
|
// notifying the user for unread messages because they would have extreme
|
||||||
|
// difficulty changing their notification preferences away from "All Messages"
|
||||||
|
// and "Noisy".
|
||||||
|
notificationCount += oldRoom.getUnreadNotificationCount("highlight");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return notificationCount;
|
||||||
|
},
|
||||||
|
|
||||||
makeRoomTile: function(room) {
|
makeRoomTile: function(room) {
|
||||||
return <RoomTile
|
return <RoomTile
|
||||||
room={room}
|
room={room}
|
||||||
|
@ -146,8 +169,8 @@ const RoomSubList = React.createClass({
|
||||||
key={room.roomId}
|
key={room.roomId}
|
||||||
collapsed={this.props.collapsed || false}
|
collapsed={this.props.collapsed || false}
|
||||||
unread={Unread.doesRoomHaveUnreadMessages(room)}
|
unread={Unread.doesRoomHaveUnreadMessages(room)}
|
||||||
highlight={room.getUnreadNotificationCount('highlight') > 0 || this.props.isInvite}
|
highlight={this.props.isInvite || this.getUnreadNotificationCount(room, 'highlight') > 0}
|
||||||
notificationCount={room.getUnreadNotificationCount()}
|
notificationCount={this.getUnreadNotificationCount(room)}
|
||||||
isInvite={this.props.isInvite}
|
isInvite={this.props.isInvite}
|
||||||
refreshSubList={this._updateSubListCount}
|
refreshSubList={this._updateSubListCount}
|
||||||
incomingCall={null}
|
incomingCall={null}
|
||||||
|
|
|
@ -52,6 +52,7 @@ import RoomScrollStateStore from '../../stores/RoomScrollStateStore';
|
||||||
import WidgetEchoStore from '../../stores/WidgetEchoStore';
|
import WidgetEchoStore from '../../stores/WidgetEchoStore';
|
||||||
import SettingsStore, {SettingLevel} from "../../settings/SettingsStore";
|
import SettingsStore, {SettingLevel} from "../../settings/SettingsStore";
|
||||||
import WidgetUtils from '../../utils/WidgetUtils';
|
import WidgetUtils from '../../utils/WidgetUtils';
|
||||||
|
import AccessibleButton from "../views/elements/AccessibleButton";
|
||||||
|
|
||||||
const DEBUG = false;
|
const DEBUG = false;
|
||||||
let debuglog = function() {};
|
let debuglog = function() {};
|
||||||
|
@ -1515,6 +1516,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() {
|
render: function() {
|
||||||
const RoomHeader = sdk.getComponent('rooms.RoomHeader');
|
const RoomHeader = sdk.getComponent('rooms.RoomHeader');
|
||||||
const MessageComposer = sdk.getComponent('rooms.MessageComposer');
|
const MessageComposer = sdk.getComponent('rooms.MessageComposer');
|
||||||
|
@ -1673,6 +1693,8 @@ module.exports = React.createClass({
|
||||||
!MatrixClientPeg.get().getKeyBackupEnabled()
|
!MatrixClientPeg.get().getKeyBackupEnabled()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const hiddenHighlightCount = this._getHiddenHighlightCount();
|
||||||
|
|
||||||
let aux = null;
|
let aux = null;
|
||||||
let hideCancel = false;
|
let hideCancel = false;
|
||||||
if (this.state.forwardingEvent !== null) {
|
if (this.state.forwardingEvent !== null) {
|
||||||
|
@ -1713,6 +1735,16 @@ module.exports = React.createClass({
|
||||||
room={this.state.room}
|
room={this.state.room}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
} else if (hiddenHighlightCount > 0) {
|
||||||
|
aux = (
|
||||||
|
<AccessibleButton element="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},
|
||||||
|
)}
|
||||||
|
</AccessibleButton>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auxPanel = (
|
const auxPanel = (
|
||||||
|
|
|
@ -1420,6 +1420,8 @@
|
||||||
"Unknown room %(roomId)s": "Unknown room %(roomId)s",
|
"Unknown room %(roomId)s": "Unknown room %(roomId)s",
|
||||||
"Room": "Room",
|
"Room": "Room",
|
||||||
"Failed to reject invite": "Failed to reject invite",
|
"Failed to reject invite": "Failed to reject invite",
|
||||||
|
"You have %(count)s unread notifications in a prior version of this room.|other": "You have %(count)s unread notifications in a prior version of this room.",
|
||||||
|
"You have %(count)s unread notifications in a prior version of this room.|one": "You have %(count)s unread notification in a prior version of this room.",
|
||||||
"Fill screen": "Fill screen",
|
"Fill screen": "Fill screen",
|
||||||
"Click to unmute video": "Click to unmute video",
|
"Click to unmute video": "Click to unmute video",
|
||||||
"Click to mute video": "Click to mute video",
|
"Click to mute video": "Click to mute video",
|
||||||
|
|
Loading…
Reference in a new issue