Add options to pin unread/mentioned rooms to the top of the room list
Fixes https://github.com/vector-im/riot-web/issues/6604 Fixes https://github.com/vector-im/riot-web/issues/732 Fixes https://github.com/vector-im/riot-web/issues/1104 Signed-off-by: Travis Ralston <travpc@gmail.com>
This commit is contained in:
parent
bbdc27019a
commit
52cdf60954
4 changed files with 34 additions and 1 deletions
|
@ -17,6 +17,8 @@ limitations under the License.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
import SettingsStore from "../../settings/SettingsStore";
|
||||||
|
|
||||||
var React = require('react');
|
var React = require('react');
|
||||||
var ReactDOM = require('react-dom');
|
var ReactDOM = require('react-dom');
|
||||||
var classNames = require('classnames');
|
var classNames = require('classnames');
|
||||||
|
@ -98,8 +100,10 @@ var RoomSubList = React.createClass({
|
||||||
componentWillReceiveProps: function(newProps) {
|
componentWillReceiveProps: function(newProps) {
|
||||||
// order the room list appropriately before we re-render
|
// order the room list appropriately before we re-render
|
||||||
//if (debug) console.log("received new props, list = " + newProps.list);
|
//if (debug) console.log("received new props, list = " + newProps.list);
|
||||||
|
const filteredRooms = this.applySearchFilter(newProps.list, newProps.searchFilter);
|
||||||
|
const sortedRooms = newProps.order === "recent" ? this.applyPinnedTileRules(filteredRooms) : filteredRooms;
|
||||||
this.setState({
|
this.setState({
|
||||||
sortedList: this.applySearchFilter(newProps.list, newProps.searchFilter),
|
sortedList: sortedRooms,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -110,6 +114,21 @@ var RoomSubList = React.createClass({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
applyPinnedTileRules: function(list) {
|
||||||
|
const pinUnread = SettingsStore.getValue("pinUnreadRooms");
|
||||||
|
const pinMentioned = SettingsStore.getValue("pinMentionedRooms");
|
||||||
|
if (!pinUnread && !pinMentioned) {
|
||||||
|
return list; // Nothing to sort
|
||||||
|
}
|
||||||
|
|
||||||
|
const mentioned = !pinMentioned ? [] : list.filter(room => room.getUnreadNotificationCount("highlight") > 0);
|
||||||
|
const unread = !pinUnread ? [] : list.filter(room => Unread.doesRoomHaveUnreadMessages(room));
|
||||||
|
|
||||||
|
return mentioned
|
||||||
|
.concat(unread.filter(room => !mentioned.find(other => other === room)))
|
||||||
|
.concat(list.filter(room => !unread.find(other => other === room)));
|
||||||
|
},
|
||||||
|
|
||||||
// The header is collapsable if it is hidden or not stuck
|
// The header is collapsable if it is hidden or not stuck
|
||||||
// The dataset elements are added in the RoomList _initAndPositionStickyHeaders method
|
// The dataset elements are added in the RoomList _initAndPositionStickyHeaders method
|
||||||
isCollapsableOnClick: function() {
|
isCollapsableOnClick: function() {
|
||||||
|
|
|
@ -81,6 +81,8 @@ const SIMPLE_SETTINGS = [
|
||||||
{ id: "VideoView.flipVideoHorizontally" },
|
{ id: "VideoView.flipVideoHorizontally" },
|
||||||
{ id: "TagPanel.disableTagPanel" },
|
{ id: "TagPanel.disableTagPanel" },
|
||||||
{ id: "enableWidgetScreenshots" },
|
{ id: "enableWidgetScreenshots" },
|
||||||
|
{ id: "pinMentionedRooms" },
|
||||||
|
{ id: "pinUnreadRooms" },
|
||||||
];
|
];
|
||||||
|
|
||||||
// These settings must be defined in SettingsStore
|
// These settings must be defined in SettingsStore
|
||||||
|
|
|
@ -218,6 +218,8 @@
|
||||||
"Enable URL previews for this room (only affects you)": "Enable URL previews for this room (only affects you)",
|
"Enable URL previews for this room (only affects you)": "Enable URL previews for this room (only affects you)",
|
||||||
"Enable URL previews by default for participants in this room": "Enable URL previews by default for participants in this room",
|
"Enable URL previews by default for participants in this room": "Enable URL previews by default for participants in this room",
|
||||||
"Room Colour": "Room Colour",
|
"Room Colour": "Room Colour",
|
||||||
|
"Pin unread rooms to the top of the room list": "Pin unread rooms to the top of the room list",
|
||||||
|
"Pin rooms I'm mentioned in to the top of the room list": "Pin rooms I'm mentioned in to the top of the room list",
|
||||||
"Enable widget screenshots on supported widgets": "Enable widget screenshots on supported widgets",
|
"Enable widget screenshots on supported widgets": "Enable widget screenshots on supported widgets",
|
||||||
"Collecting app version information": "Collecting app version information",
|
"Collecting app version information": "Collecting app version information",
|
||||||
"Collecting logs": "Collecting logs",
|
"Collecting logs": "Collecting logs",
|
||||||
|
|
|
@ -269,6 +269,16 @@ export const SETTINGS = {
|
||||||
default: true,
|
default: true,
|
||||||
controller: new AudioNotificationsEnabledController(),
|
controller: new AudioNotificationsEnabledController(),
|
||||||
},
|
},
|
||||||
|
"pinMentionedRooms": {
|
||||||
|
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||||
|
displayName: _td("Pin rooms I'm mentioned in to the top of the room list"),
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
"pinUnreadRooms": {
|
||||||
|
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||||
|
displayName: _td("Pin unread rooms to the top of the room list"),
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
"enableWidgetScreenshots": {
|
"enableWidgetScreenshots": {
|
||||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||||
displayName: _td('Enable widget screenshots on supported widgets'),
|
displayName: _td('Enable widget screenshots on supported widgets'),
|
||||||
|
|
Loading…
Reference in a new issue