Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
7fc21f4423
1 changed files with 30 additions and 20 deletions
|
@ -93,8 +93,9 @@ module.exports = React.createClass({
|
||||||
this._visibleRoomsForGroup = {
|
this._visibleRoomsForGroup = {
|
||||||
// $groupId: [$roomId1, $roomId2, ...],
|
// $groupId: [$roomId1, $roomId2, ...],
|
||||||
};
|
};
|
||||||
// All rooms that should be kept in the room list when filtering
|
// All rooms that should be kept in the room list when filtering.
|
||||||
this._visibleRooms = [];
|
// By default, show all rooms.
|
||||||
|
this._visibleRooms = MatrixClientPeg.get().getRooms();
|
||||||
// When the selected tags are changed, initialise a group store if necessary
|
// When the selected tags are changed, initialise a group store if necessary
|
||||||
this._tagStoreToken = TagOrderStore.addListener(() => {
|
this._tagStoreToken = TagOrderStore.addListener(() => {
|
||||||
(TagOrderStore.getOrderedTags() || []).forEach((tag) => {
|
(TagOrderStore.getOrderedTags() || []).forEach((tag) => {
|
||||||
|
@ -197,11 +198,11 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onRoom: function(room) {
|
onRoom: function(room) {
|
||||||
this._delayedRefreshRoomList();
|
this.updateVisibleRooms();
|
||||||
},
|
},
|
||||||
|
|
||||||
onDeleteRoom: function(roomId) {
|
onDeleteRoom: function(roomId) {
|
||||||
this._delayedRefreshRoomList();
|
this.updateVisibleRooms();
|
||||||
},
|
},
|
||||||
|
|
||||||
onArchivedHeaderClick: function(isHidden, scrollToPosition) {
|
onArchivedHeaderClick: function(isHidden, scrollToPosition) {
|
||||||
|
@ -298,25 +299,39 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
// Update which rooms and users should appear according to which tags are selected
|
// Update which rooms and users should appear according to which tags are selected
|
||||||
updateVisibleRooms: function() {
|
updateVisibleRooms: function() {
|
||||||
this._visibleRooms = [];
|
const selectedTags = TagOrderStore.getSelectedTags();
|
||||||
TagOrderStore.getSelectedTags().forEach((tag) => {
|
const visibleGroupRooms = [];
|
||||||
|
selectedTags.forEach((tag) => {
|
||||||
(this._visibleRoomsForGroup[tag] || []).forEach(
|
(this._visibleRoomsForGroup[tag] || []).forEach(
|
||||||
(roomId) => this._visibleRooms.push(roomId),
|
(roomId) => visibleGroupRooms.push(roomId),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// If there are any tags selected, constrain the rooms listed to the
|
||||||
|
// visible rooms as determined by visibleGroupRooms. Here, we
|
||||||
|
// de-duplicate and filter out rooms that the client doesn't know
|
||||||
|
// about (hence the Set and the null-guard on `room`).
|
||||||
|
if (selectedTags.length > 0) {
|
||||||
|
const roomSet = new Set();
|
||||||
|
visibleGroupRooms.forEach((roomId) => {
|
||||||
|
const room = MatrixClientPeg.get().getRoom(roomId);
|
||||||
|
if (room) {
|
||||||
|
roomSet.add(room);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this._visibleRooms = Array.from(roomSet);
|
||||||
|
} else {
|
||||||
|
// Show all rooms
|
||||||
|
this._visibleRooms = MatrixClientPeg.get().getRooms();
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
selectedTags: TagOrderStore.getSelectedTags(),
|
selectedTags,
|
||||||
}, () => {
|
}, () => {
|
||||||
this.refreshRoomList();
|
this.refreshRoomList();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
isRoomInSelectedTags: function(room) {
|
|
||||||
// No selected tags = every room is visible in the list
|
|
||||||
return this.state.selectedTags.length === 0 || this._visibleRooms.includes(room.roomId);
|
|
||||||
},
|
|
||||||
|
|
||||||
refreshRoomList: function() {
|
refreshRoomList: function() {
|
||||||
// TODO: ideally we'd calculate this once at start, and then maintain
|
// TODO: ideally we'd calculate this once at start, and then maintain
|
||||||
// any changes to it incrementally, updating the appropriate sublists
|
// any changes to it incrementally, updating the appropriate sublists
|
||||||
|
@ -345,7 +360,8 @@ module.exports = React.createClass({
|
||||||
lists["im.vector.fake.archived"] = [];
|
lists["im.vector.fake.archived"] = [];
|
||||||
|
|
||||||
const dmRoomMap = DMRoomMap.shared();
|
const dmRoomMap = DMRoomMap.shared();
|
||||||
MatrixClientPeg.get().getRooms().forEach((room) => {
|
|
||||||
|
this._visibleRooms.forEach((room, index) => {
|
||||||
const me = room.getMember(MatrixClientPeg.get().credentials.userId);
|
const me = room.getMember(MatrixClientPeg.get().credentials.userId);
|
||||||
if (!me) return;
|
if (!me) return;
|
||||||
|
|
||||||
|
@ -362,12 +378,6 @@ module.exports = React.createClass({
|
||||||
(me.membership === "leave" && me.events.member.getSender() !== me.events.member.getStateKey())) {
|
(me.membership === "leave" && me.events.member.getSender() !== me.events.member.getStateKey())) {
|
||||||
// Used to split rooms via tags
|
// Used to split rooms via tags
|
||||||
const tagNames = Object.keys(room.tags);
|
const tagNames = Object.keys(room.tags);
|
||||||
|
|
||||||
// Apply TagPanel filtering, derived from TagOrderStore
|
|
||||||
if (!this.isRoomInSelectedTags(room)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tagNames.length) {
|
if (tagNames.length) {
|
||||||
for (let i = 0; i < tagNames.length; i++) {
|
for (let i = 0; i < tagNames.length; i++) {
|
||||||
const tagName = tagNames[i];
|
const tagName = tagNames[i];
|
||||||
|
|
Loading…
Reference in a new issue