room.html now displays messages from model-service. Add debugging fields. Hook up the room member *at the time* to the message so it can display the right historical member info.

This commit is contained in:
Kegan Dougal 2014-10-31 16:22:15 +00:00
parent ea80b9208d
commit b0f0b7b75e
5 changed files with 31 additions and 17 deletions

View file

@ -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;
}
},

View file

@ -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;
}
}