Merge pull request #829 from matrix-org/luke/fix-people-section-disappearing
Remove DM-guessing code
This commit is contained in:
commit
d5b49a11d7
1 changed files with 6 additions and 47 deletions
|
@ -97,7 +97,7 @@ module.exports = React.createClass({
|
||||||
if (this.props.selectedRoom) {
|
if (this.props.selectedRoom) {
|
||||||
constantTimeDispatcher.dispatch(
|
constantTimeDispatcher.dispatch(
|
||||||
"RoomTile.select", this.props.selectedRoom, {}
|
"RoomTile.select", this.props.selectedRoom, {}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
constantTimeDispatcher.dispatch(
|
constantTimeDispatcher.dispatch(
|
||||||
"RoomTile.select", nextProps.selectedRoom, { selected: true }
|
"RoomTile.select", nextProps.selectedRoom, { selected: true }
|
||||||
|
@ -265,7 +265,7 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onRoomStateMember: function(ev, state, member) {
|
onRoomStateMember: function(ev, state, member) {
|
||||||
if (ev.getStateKey() === MatrixClientPeg.get().credentials.userId &&
|
if (ev.getStateKey() === MatrixClientPeg.get().credentials.userId &&
|
||||||
ev.getPrevContent() && ev.getPrevContent().membership === "invite")
|
ev.getPrevContent() && ev.getPrevContent().membership === "invite")
|
||||||
{
|
{
|
||||||
this._delayedRefreshRoomList();
|
this._delayedRefreshRoomList();
|
||||||
|
@ -290,7 +290,7 @@ module.exports = React.createClass({
|
||||||
this._delayedRefreshRoomList();
|
this._delayedRefreshRoomList();
|
||||||
}
|
}
|
||||||
else if (ev.getType() == 'm.push_rules') {
|
else if (ev.getType() == 'm.push_rules') {
|
||||||
this._delayedRefreshRoomList();
|
this._delayedRefreshRoomList();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ module.exports = React.createClass({
|
||||||
// as needed.
|
// as needed.
|
||||||
// Alternatively we'd do something magical with Immutable.js or similar.
|
// Alternatively we'd do something magical with Immutable.js or similar.
|
||||||
this.setState(this.getRoomLists());
|
this.setState(this.getRoomLists());
|
||||||
|
|
||||||
// this._lastRefreshRoomListTs = Date.now();
|
// this._lastRefreshRoomListTs = Date.now();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -341,7 +341,7 @@ module.exports = React.createClass({
|
||||||
MatrixClientPeg.get().getRooms().forEach(function(room) {
|
MatrixClientPeg.get().getRooms().forEach(function(room) {
|
||||||
const me = room.getMember(MatrixClientPeg.get().credentials.userId);
|
const me = room.getMember(MatrixClientPeg.get().credentials.userId);
|
||||||
if (!me) return;
|
if (!me) return;
|
||||||
|
|
||||||
// console.log("room = " + room.name + ", me.membership = " + me.membership +
|
// console.log("room = " + room.name + ", me.membership = " + me.membership +
|
||||||
// ", sender = " + me.events.member.getSender() +
|
// ", sender = " + me.events.member.getSender() +
|
||||||
// ", target = " + me.events.member.getStateKey() +
|
// ", target = " + me.events.member.getStateKey() +
|
||||||
|
@ -391,51 +391,10 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (s.lists["im.vector.fake.direct"].length == 0 &&
|
|
||||||
MatrixClientPeg.get().getAccountData('m.direct') === undefined &&
|
|
||||||
!MatrixClientPeg.get().isGuest())
|
|
||||||
{
|
|
||||||
// scan through the 'recents' list for any rooms which look like DM rooms
|
|
||||||
// and make them DM rooms
|
|
||||||
const oldRecents = s.lists["im.vector.fake.recent"];
|
|
||||||
s.lists["im.vector.fake.recent"] = [];
|
|
||||||
|
|
||||||
for (const room of oldRecents) {
|
|
||||||
const me = room.getMember(MatrixClientPeg.get().credentials.userId);
|
|
||||||
|
|
||||||
if (me && Rooms.looksLikeDirectMessageRoom(room, me)) {
|
|
||||||
self.listsForRoomId[room.roomId].push("im.vector.fake.direct");
|
|
||||||
s.lists["im.vector.fake.direct"].push(room);
|
|
||||||
} else {
|
|
||||||
self.listsForRoomId[room.roomId].push("im.vector.fake.recent");
|
|
||||||
s.lists["im.vector.fake.recent"].push(room);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// save these new guessed DM rooms into the account data
|
|
||||||
const newMDirectEvent = {};
|
|
||||||
for (const room of s.lists["im.vector.fake.direct"]) {
|
|
||||||
const me = room.getMember(MatrixClientPeg.get().credentials.userId);
|
|
||||||
const otherPerson = Rooms.getOnlyOtherMember(room, me);
|
|
||||||
if (!otherPerson) continue;
|
|
||||||
|
|
||||||
const roomList = newMDirectEvent[otherPerson.userId] || [];
|
|
||||||
roomList.push(room.roomId);
|
|
||||||
newMDirectEvent[otherPerson.userId] = roomList;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.warn("Resetting room DM state to be " + JSON.stringify(newMDirectEvent));
|
|
||||||
|
|
||||||
// if this fails, fine, we'll just do the same thing next time we get the room lists
|
|
||||||
MatrixClientPeg.get().setAccountData('m.direct', newMDirectEvent).done();
|
|
||||||
}
|
|
||||||
|
|
||||||
//console.log("calculated new roomLists; im.vector.fake.recent = " + s.lists["im.vector.fake.recent"]);
|
|
||||||
|
|
||||||
// we actually apply the sorting to this when receiving the prop in RoomSubLists.
|
// we actually apply the sorting to this when receiving the prop in RoomSubLists.
|
||||||
|
|
||||||
// we'll need this when we get to iterating through lists programatically - e.g. ctrl-shift-up/down
|
// we'll need this when we get to iterating through lists programatically - e.g. ctrl-shift-up/down
|
||||||
/*
|
/*
|
||||||
this.listOrder = [
|
this.listOrder = [
|
||||||
"im.vector.fake.invite",
|
"im.vector.fake.invite",
|
||||||
"m.favourite",
|
"m.favourite",
|
||||||
|
|
Loading…
Reference in a new issue