diff options
Diffstat (limited to 'syweb')
-rw-r--r-- | syweb/webclient/components/matrix/event-handler-service.js | 9 | ||||
-rw-r--r-- | syweb/webclient/components/matrix/matrix-call.js | 2 | ||||
-rw-r--r-- | syweb/webclient/components/matrix/matrix-filter.js | 8 | ||||
-rw-r--r-- | syweb/webclient/components/matrix/model-service.js | 4 | ||||
-rw-r--r-- | syweb/webclient/recents/recents-filter.js | 3 | ||||
-rw-r--r-- | syweb/webclient/room/room-controller.js | 4 | ||||
-rw-r--r-- | syweb/webclient/test/unit/event-handler-service.spec.js | 38 | ||||
-rw-r--r-- | syweb/webclient/test/unit/filters.spec.js | 12 | ||||
-rw-r--r-- | syweb/webclient/test/unit/model-service.spec.js | 2 |
9 files changed, 52 insertions, 30 deletions
diff --git a/syweb/webclient/components/matrix/event-handler-service.js b/syweb/webclient/components/matrix/event-handler-service.js index 38a6efced7..a9c6eb34c7 100644 --- a/syweb/webclient/components/matrix/event-handler-service.js +++ b/syweb/webclient/components/matrix/event-handler-service.js @@ -141,7 +141,7 @@ function(matrixService, $rootScope, $q, $timeout, $filter, mPresence, notificati notificationService.showNotification( displayname + " (" + roomTitle + ")", message, - member ? member.avatar_url : undefined, + member ? member.event.content.avatar_url : undefined, function() { console.log("notification.onclick() room=" + event.room_id); $rootScope.goToPage('room/' + event.room_id); @@ -306,6 +306,9 @@ function(matrixService, $rootScope, $q, $timeout, $filter, mPresence, notificati // Get the user display name from the member list of the room var member = modelService.getMember(room_id, user_id); + if (member) { + member = member.event; + } if (member && member.content.displayname) { // Do not consider null displayname displayName = member.content.displayname; @@ -315,7 +318,7 @@ function(matrixService, $rootScope, $q, $timeout, $filter, mPresence, notificati for (var member_id in room.current_room_state.members) { if (room.current_room_state.members.hasOwnProperty(member_id) && member_id !== user_id) { - var member2 = room.current_room_state.members[member_id]; + var member2 = room.current_room_state.members[member_id].event; if (member2.content.displayname && member2.content.displayname === displayName) { displayName = displayName + " (" + user_id + ")"; break; @@ -551,7 +554,7 @@ function(matrixService, $rootScope, $q, $timeout, $filter, mPresence, notificati for (var i in room.current_room_state.members) { if (!room.current_room_state.members.hasOwnProperty(i)) continue; - var member = room.current_room_state.members[i]; + var member = room.current_room_state.members[i].event; if ("join" === member.content.membership) { memberCount = memberCount + 1; diff --git a/syweb/webclient/components/matrix/matrix-call.js b/syweb/webclient/components/matrix/matrix-call.js index 5a2807c755..465b2b7807 100644 --- a/syweb/webclient/components/matrix/matrix-call.js +++ b/syweb/webclient/components/matrix/matrix-call.js @@ -214,7 +214,7 @@ angular.module('MatrixCall', []) var self = this; var roomMembers = modelService.getRoom(this.room_id).current_room_state.members; - if (roomMembers[matrixService.config().user_id].membership != 'join') { + if (roomMembers[matrixService.config().user_id].event.content.membership != 'join') { console.log("We need to join the room before we can accept this call"); matrixService.join(this.room_id).then(function() { self.answer(); diff --git a/syweb/webclient/components/matrix/matrix-filter.js b/syweb/webclient/components/matrix/matrix-filter.js index e84c197c76..aeebedc784 100644 --- a/syweb/webclient/components/matrix/matrix-filter.js +++ b/syweb/webclient/components/matrix/matrix-filter.js @@ -53,7 +53,7 @@ function($rootScope, matrixService, eventHandlerService, modelService) { for (var i in room.members) { if (!room.members.hasOwnProperty(i)) continue; - var member = room.members[i]; + var member = room.members[i].event; if (member.state_key !== user_id) { roomName = eventHandlerService.getUserDisplayName(room_id, member.state_key); if (!roomName) { @@ -70,11 +70,11 @@ function($rootScope, matrixService, eventHandlerService, modelService) { if (otherUserId === user_id) { // it's us, we may have been invited to this room or it could // be a self chat. - if (room.members[otherUserId].content.membership === "invite") { + if (room.members[otherUserId].event.content.membership === "invite") { // someone invited us, use the right ID. - roomName = eventHandlerService.getUserDisplayName(room_id, room.members[otherUserId].user_id); + roomName = eventHandlerService.getUserDisplayName(room_id, room.members[otherUserId].event.user_id); if (!roomName) { - roomName = room.members[otherUserId].user_id; + roomName = room.members[otherUserId].event.user_id; } } else { diff --git a/syweb/webclient/components/matrix/model-service.js b/syweb/webclient/components/matrix/model-service.js index 8b2ee877b1..8e0ce8d1a9 100644 --- a/syweb/webclient/components/matrix/model-service.js +++ b/syweb/webclient/components/matrix/model-service.js @@ -106,7 +106,9 @@ angular.module('modelService', []) storeStateEvent: function storeState(event) { this.state_events[event.type + event.state_key] = event; if (event.type === "m.room.member") { - this.members[event.state_key] = event; + var rm = new RoomMember(); + rm.event = event; + this.members[event.state_key] = rm; } }, diff --git a/syweb/webclient/recents/recents-filter.js b/syweb/webclient/recents/recents-filter.js index 39c2359967..cfbc6f4bd8 100644 --- a/syweb/webclient/recents/recents-filter.js +++ b/syweb/webclient/recents/recents-filter.js @@ -30,6 +30,9 @@ angular.module('RecentsController') // Show the room only if the user has joined it or has been invited // (ie, do not show it if he has been banned) var member = modelService.getMember(room_id, user_id); + if (member) { + member = member.event; + } room.recent.me = member; if (member && ("invite" === member.content.membership || "join" === member.content.membership)) { if ("invite" === member.content.membership) { diff --git a/syweb/webclient/room/room-controller.js b/syweb/webclient/room/room-controller.js index a2bc23195d..d3fb85b9dc 100644 --- a/syweb/webclient/room/room-controller.js +++ b/syweb/webclient/room/room-controller.js @@ -754,13 +754,13 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput']) for (var i in members) { if (!members.hasOwnProperty(i)) continue; - var member = members[i]; + var member = members[i].event; updateMemberList(member); } // Check if the user has already join the room if ($scope.state.user_id in members) { - if ("join" === members[$scope.state.user_id].membership) { + if ("join" === members[$scope.state.user_id].event.content.membership) { needsToJoin = false; } } diff --git a/syweb/webclient/test/unit/event-handler-service.spec.js b/syweb/webclient/test/unit/event-handler-service.spec.js index 023abec98b..2a4dc3b5a5 100644 --- a/syweb/webclient/test/unit/event-handler-service.spec.js +++ b/syweb/webclient/test/unit/event-handler-service.spec.js @@ -36,20 +36,28 @@ describe('EventHandlerService', function() { current_room_state: { members: { "@adam:matrix.org": { - content: { membership: "join" }, - user_id: "@adam:matrix.org" + event: { + content: { membership: "join" }, + user_id: "@adam:matrix.org" + } }, "@beth:matrix.org": { - content: { membership: "invite" }, - user_id: "@beth:matrix.org" + event: { + content: { membership: "invite" }, + user_id: "@beth:matrix.org" + } }, "@charlie:matrix.org": { - content: { membership: "join" }, - user_id: "@charlie:matrix.org" + event: { + content: { membership: "join" }, + user_id: "@charlie:matrix.org" + } }, "@danice:matrix.org": { - content: { membership: "leave" }, - user_id: "@danice:matrix.org" + event: { + content: { membership: "leave" }, + user_id: "@danice:matrix.org" + } } } } @@ -70,12 +78,16 @@ describe('EventHandlerService', function() { current_room_state: { members: { "@adam:matrix.org": { - content: { membership: "join" }, - user_id: "@adam:matrix.org" + event: { + content: { membership: "join" }, + user_id: "@adam:matrix.org" + } }, "@beth:matrix.org": { - content: { membership: "join" }, - user_id: "@beth:matrix.org" + event: { + content: { membership: "join" }, + user_id: "@beth:matrix.org" + } } }, s: { @@ -102,4 +114,4 @@ describe('EventHandlerService', function() { num = eventHandlerService.getUserPowerLevel(roomId, "@unknown:matrix.org"); expect(num).toEqual(50); })); -}); \ No newline at end of file +}); diff --git a/syweb/webclient/test/unit/filters.spec.js b/syweb/webclient/test/unit/filters.spec.js index 2e8d0c4036..7324a8e028 100644 --- a/syweb/webclient/test/unit/filters.spec.js +++ b/syweb/webclient/test/unit/filters.spec.js @@ -86,11 +86,13 @@ describe('mRoomName filter', function() { inviter_user_id = user_id; } this.s["m.room.member" + user_id] = { - content: { - membership: membership - }, - state_key: user_id, - user_id: inviter_user_id + event: { + content: { + membership: membership + }, + state_key: user_id, + user_id: inviter_user_id + } }; this.members[user_id] = this.s["m.room.member" + user_id]; } diff --git a/syweb/webclient/test/unit/model-service.spec.js b/syweb/webclient/test/unit/model-service.spec.js index 2e012efe90..e2fa8ceba3 100644 --- a/syweb/webclient/test/unit/model-service.spec.js +++ b/syweb/webclient/test/unit/model-service.spec.js @@ -25,6 +25,6 @@ describe('ModelService', function() { }); var user = modelService.getMember(roomId, userId); - expect(user.state_key).toEqual(userId); + expect(user.event.state_key).toEqual(userId); })); }); |