diff options
Diffstat (limited to 'webclient/components')
-rw-r--r-- | webclient/components/matrix/event-handler-service.js | 9 | ||||
-rw-r--r-- | webclient/components/matrix/model-service.js | 16 |
2 files changed, 18 insertions, 7 deletions
diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js index 589554ec08..a511b394b8 100644 --- a/webclient/components/matrix/event-handler-service.js +++ b/webclient/components/matrix/event-handler-service.js @@ -96,7 +96,7 @@ function(matrixService, $rootScope, $q, $timeout, mPresence, notificationService __room.old_room_state.storeStateEvents(room.state); __room.old_room_state.pagination_token = room.messages.start; - __room.addMessageEvents(room.messages.chunk); + $rootScope["debug_"+room_id] = __room; } }; @@ -589,6 +589,10 @@ function(matrixService, $rootScope, $q, $timeout, mPresence, notificationService // Store how far back we've paginated $rootScope.events.rooms[room_id].pagination.earliest_token = messages.end; + + var __room = modelService.getRoom(room_id); + __room.old_room_state.pagination_token = messages.end; + } else { // InitialSync returns messages in chronological order @@ -597,6 +601,9 @@ function(matrixService, $rootScope, $q, $timeout, mPresence, notificationService } // Store where to start pagination $rootScope.events.rooms[room_id].pagination.earliest_token = messages.start; + + var __room = modelService.getRoom(room_id); + __room.old_room_state.pagination_token = messages.start; } }, diff --git a/webclient/components/matrix/model-service.js b/webclient/components/matrix/model-service.js index 6e1576cd62..d47ac6b2a9 100644 --- a/webclient/components/matrix/model-service.js +++ b/webclient/components/matrix/model-service.js @@ -33,7 +33,7 @@ angular.module('modelService', []) this.room_id = room_id; this.old_room_state = new RoomState(); this.current_room_state = new RoomState(); - this.messages = []; // events which can be displayed on the UI. TODO move? + this.events = []; // events which can be displayed on the UI. TODO move? }; Room.prototype = { addMessageEvents: function addMessageEvents(events, toFront) { @@ -43,22 +43,26 @@ angular.module('modelService', []) }, addMessageEvent: function addMessageEvent(event, toFront) { + // every message must reference the RoomMember which made it *at + // that time* so things like display names display correctly. if (toFront) { - this.messages.unshift(event); + event.room_member = this.old_room_state.getStateEvent("m.room.member", event.user_id); + this.events.unshift(event); } else { - this.messages.push(event); + event.room_member = this.current_room_state.getStateEvent("m.room.member", event.user_id); + this.events.push(event); } }, addOrReplaceMessageEvent: function addOrReplaceMessageEvent(event, toFront) { // Start looking from the tail since the first goal of this function // is to find a message among the latest ones - for (var i = this.messages.length - 1; i >= 0; i--) { - var storedEvent = this.messages[i]; + for (var i = this.events.length - 1; i >= 0; i--) { + var storedEvent = this.events[i]; if (storedEvent.event_id === event.event_id) { // It's clobbering time! - this.messages[i] = event; + this.events[i] = event; return; } } |