diff --git a/src/RoomInvite.js b/src/RoomInvite.js
index 3a9088e65f9..a96d1b2f6b5 100644
--- a/src/RoomInvite.js
+++ b/src/RoomInvite.js
@@ -194,8 +194,7 @@ function _getDirectMessageRooms(addr) {
const rooms = dmRooms.filter((dmRoom) => {
const room = MatrixClientPeg.get().getRoom(dmRoom);
if (room) {
- const me = room.getMember(MatrixClientPeg.get().credentials.userId);
- return me && me.membership == 'join';
+ return room.getMyMembership() === 'join';
}
});
return rooms;
diff --git a/src/VectorConferenceHandler.js b/src/VectorConferenceHandler.js
index 19081726b29..af6659d343d 100644
--- a/src/VectorConferenceHandler.js
+++ b/src/VectorConferenceHandler.js
@@ -84,7 +84,7 @@ ConferenceCall.prototype._getConferenceUserRoom = function() {
preset: "private_chat",
invite: [this.confUserId]
}).then(function(res) {
- return new Room(res.room_id);
+ return new Room(res.room_id, client.getUserId());
});
};
diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js
index c7429753778..08bed976cc6 100644
--- a/src/components/structures/RoomView.js
+++ b/src/components/structures/RoomView.js
@@ -758,15 +758,13 @@ module.exports = React.createClass({
},
_updateDMState() {
- const me = this.state.room.getMember(MatrixClientPeg.get().getUserId());
- if (!me || me.membership !== "join") {
+ const room = this.state.room;
+ if (room.getMyMembership() != "join") {
return;
}
- const roomId = this.state.room.roomId;
- const dmInviter = me.getDMInviter();
-
+ const dmInviter = room.getDMInviter();
if (dmInviter) {
- Rooms.setDMRoom(roomId, dmInviter);
+ Rooms.setDMRoom(room.roomId, dmInviter);
}
},
diff --git a/src/components/views/dialogs/ChatCreateOrReuseDialog.js b/src/components/views/dialogs/ChatCreateOrReuseDialog.js
index b7cf0f5a6e1..550abe52998 100644
--- a/src/components/views/dialogs/ChatCreateOrReuseDialog.js
+++ b/src/components/views/dialogs/ChatCreateOrReuseDialog.js
@@ -54,8 +54,8 @@ export default class ChatCreateOrReuseDialog extends React.Component {
for (const roomId of dmRooms) {
const room = client.getRoom(roomId);
if (room) {
- const me = room.getMember(client.credentials.userId);
- const highlight = room.getUnreadNotificationCount('highlight') > 0 || me.membership === "invite";
+ const isInvite = room.getMyMembership() === "invite";
+ const highlight = room.getUnreadNotificationCount('highlight') > 0 || isInvite;
tiles.push(
,
);
diff --git a/src/components/views/rooms/MemberInfo.js b/src/components/views/rooms/MemberInfo.js
index 8b465cef9d3..c635f09e2c8 100644
--- a/src/components/views/rooms/MemberInfo.js
+++ b/src/components/views/rooms/MemberInfo.js
@@ -774,15 +774,15 @@ module.exports = withMatrixClient(React.createClass({
for (const roomId of dmRooms) {
const room = this.props.matrixClient.getRoom(roomId);
if (room) {
- const me = room.getMember(this.props.matrixClient.credentials.userId);
-
+ const myMembership = room.getMyMembership();
// not a DM room if we have are not joined
- if (!me.membership || me.membership !== 'join') continue;
- // not a DM room if they are not joined
+ if (myMembership !== 'join') continue;
+
const them = this.props.member;
+ // not a DM room if they are not joined
if (!them.membership || them.membership !== 'join') continue;
- const highlight = room.getUnreadNotificationCount('highlight') > 0 || me.membership === 'invite';
+ const highlight = room.getUnreadNotificationCount('highlight') > 0;
tiles.push(
,
);
diff --git a/src/components/views/rooms/RoomTile.js b/src/components/views/rooms/RoomTile.js
index ee7f8a76c7e..d73f9b5ccff 100644
--- a/src/components/views/rooms/RoomTile.js
+++ b/src/components/views/rooms/RoomTile.js
@@ -243,9 +243,7 @@ module.exports = React.createClass({
},
render: function() {
- const myUserId = MatrixClientPeg.get().credentials.userId;
- const me = this.props.room.currentState.members[myUserId];
-
+ const isInvite = this.props.room.getMyMembership() === "invite";
const notificationCount = this.state.notificationCount;
// var highlightCount = this.props.room.getUnreadNotificationCount("highlight");
@@ -259,7 +257,7 @@ module.exports = React.createClass({
'mx_RoomTile_unread': this.props.unread,
'mx_RoomTile_unreadNotify': notifBadges,
'mx_RoomTile_highlight': mentionBadges,
- 'mx_RoomTile_invited': (me && me.membership === 'invite'),
+ 'mx_RoomTile_invited': isInvite,
'mx_RoomTile_menuDisplayed': this.state.menuDisplayed,
'mx_RoomTile_noBadges': !badges,
'mx_RoomTile_transparent': this.props.transparent,
diff --git a/src/utils/WidgetUtils.js b/src/utils/WidgetUtils.js
index 008bed1005a..b5a2ae31fb8 100644
--- a/src/utils/WidgetUtils.js
+++ b/src/utils/WidgetUtils.js
@@ -77,8 +77,7 @@ export default class WidgetUtils {
return false;
}
- const member = room.getMember(me);
- if (!member || member.membership !== "join") {
+ if (room.getMyMembership() !== "join") {
console.warn(`User ${me} is not in room ${roomId}`);
return false;
}
diff --git a/test/components/views/rooms/RoomList-test.js b/test/components/views/rooms/RoomList-test.js
index c0a0b8eb67e..8a596d41518 100644
--- a/test/components/views/rooms/RoomList-test.js
+++ b/test/components/views/rooms/RoomList-test.js
@@ -20,15 +20,16 @@ function generateRoomId() {
return '!' + Math.random().toString().slice(2, 10) + ':domain';
}
-function createRoom(opts) {
- const room = new Room(generateRoomId());
- if (opts) {
- Object.assign(room, opts);
- }
- return room;
-}
describe('RoomList', () => {
+ function createRoom(opts) {
+ const room = new Room(generateRoomId(), client.getUserId());
+ if (opts) {
+ Object.assign(room, opts);
+ }
+ return room;
+ }
+
let parentDiv = null;
let sandbox = null;
let client = null;