diff options
author | Kegan Dougal <kegan@matrix.org> | 2014-10-31 16:22:15 +0000 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2014-10-31 16:22:15 +0000 |
commit | b0f0b7b75e2887be546ac7c5e1d3dabec8d7052c (patch) | |
tree | dba63317dc9697139dea272400310cada1a1d246 /webclient | |
parent | Hook into more of event-handler-service and mimic its functions for now. (diff) | |
download | synapse-b0f0b7b75e2887be546ac7c5e1d3dabec8d7052c.tar.xz |
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.
Diffstat (limited to 'webclient')
-rw-r--r-- | webclient/components/matrix/event-handler-service.js | 9 | ||||
-rw-r--r-- | webclient/components/matrix/model-service.js | 16 | ||||
-rw-r--r-- | webclient/index.html | 2 | ||||
-rw-r--r-- | webclient/room/room-controller.js | 11 | ||||
-rw-r--r-- | webclient/room/room.html | 10 |
5 files changed, 31 insertions, 17 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; } } diff --git a/webclient/index.html b/webclient/index.html index 965981f7de..3ed968a5ea 100644 --- a/webclient/index.html +++ b/webclient/index.html @@ -13,7 +13,7 @@ <script type='text/javascript' src='js/jquery-1.8.3.min.js'></script> <script type="text/javascript" src="https://www.google.com/recaptcha/api/js/recaptcha_ajax.js"></script> - <script src="js/angular.min.js"></script> + <script src="js/angular.js"></script> <script src="js/angular-route.min.js"></script> <script src="js/angular-sanitize.min.js"></script> <script src="js/angular-animate.min.js"></script> diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js index 486ead0da9..7125c98e02 100644 --- a/webclient/room/room-controller.js +++ b/webclient/room/room-controller.js @@ -15,8 +15,8 @@ limitations under the License. */ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput']) -.controller('RoomController', ['$modal', '$filter', '$scope', '$timeout', '$routeParams', '$location', '$rootScope', 'matrixService', 'mPresence', 'eventHandlerService', 'mFileUpload', 'matrixPhoneService', 'MatrixCall', 'notificationService', - function($modal, $filter, $scope, $timeout, $routeParams, $location, $rootScope, matrixService, mPresence, eventHandlerService, mFileUpload, matrixPhoneService, MatrixCall, notificationService) { +.controller('RoomController', ['$modal', '$filter', '$scope', '$timeout', '$routeParams', '$location', '$rootScope', 'matrixService', 'mPresence', 'eventHandlerService', 'mFileUpload', 'matrixPhoneService', 'MatrixCall', 'notificationService', 'modelService', + function($modal, $filter, $scope, $timeout, $routeParams, $location, $rootScope, matrixService, mPresence, eventHandlerService, mFileUpload, matrixPhoneService, MatrixCall, notificationService, modelService) { 'use strict'; var MESSAGES_PER_PAGINATION = 30; var THUMBNAIL_SIZE = 320; @@ -254,11 +254,11 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput']) $scope.state.paginating = true; } - console.log("paginateBackMessages from " + $rootScope.events.rooms[$scope.room_id].pagination.earliest_token + " for " + numItems); + console.log("paginateBackMessages from " + $scope.room.old_room_state.pagination_token + " for " + numItems); var originalTopRow = $("#messageTable>tbody>tr:first")[0]; // Paginate events from the point in cache - matrixService.paginateBackMessages($scope.room_id, $rootScope.events.rooms[$scope.room_id].pagination.earliest_token, numItems).then( + matrixService.paginateBackMessages($scope.room_id, $scope.room.old_room_state.pagination_token, numItems).then( function(response) { eventHandlerService.handleRoomMessages($scope.room_id, response.data, false, 'b'); @@ -717,6 +717,9 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput']) var onInit2 = function() { console.log("onInit2"); + // ============================= + $scope.room = modelService.getRoom($scope.room_id); + // ============================= // Scroll down as soon as possible so that we point to the last message // if it already exists in memory diff --git a/webclient/room/room.html b/webclient/room/room.html index 5265f42dd8..8c1e45dfd4 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -123,10 +123,10 @@ ng-style="{ 'visibility': state.messages_visibility }" keep-scroll> <table id="messageTable" infinite-scroll="paginateMore()"> - <tr ng-repeat="msg in events.rooms[room_id].messages" - ng-class="(events.rooms[room_id].messages[$index + 1].user_id !== msg.user_id ? 'differentUser' : '') + (msg.user_id === state.user_id ? ' mine' : '')" scroll-item> + <tr ng-repeat="msg in room.events track by $index" + ng-class="(room.events[$index + 1].user_id !== msg.user_id ? 'differentUser' : '') + (msg.user_id === state.user_id ? ' mine' : '')" scroll-item> <td class="leftBlock"> - <div class="sender" ng-hide="events.rooms[room_id].messages[$index - 1].user_id === msg.user_id"> {{ msg.user_id | mUserDisplayName: room_id }}</div> + <div class="sender" ng-hide="room.events[$index - 1].user_id === msg.user_id"> {{ msg.user_id | mUserDisplayName: room_id }}</div> <div class="timestamp" ng-class="msg.echo_msg_state"> {{ (msg.origin_server_ts) | date:'MMM d HH:mm' }} @@ -134,7 +134,7 @@ </td> <td class="avatar"> <img class="avatarImage" ng-src="{{ members[msg.user_id].avatar_url || 'img/default-profile.png' }}" width="32" height="32" title="{{msg.user_id}}" - ng-hide="events.rooms[room_id].messages[$index - 1].user_id === msg.user_id || msg.user_id === state.user_id"/> + ng-hide="room.events[$index - 1].user_id === msg.user_id || msg.user_id === state.user_id"/> </td> <td ng-class="(!msg.content.membership && ('m.room.topic' !== msg.type && 'm.room.name' !== msg.type))? (msg.content.msgtype === 'm.emote' ? 'emote text' : 'text') : 'membership text'"> <div class="bubble" ng-click="openJson(msg)"> @@ -204,7 +204,7 @@ </td> <td class="rightBlock"> <img class="avatarImage" ng-src="{{ members[msg.user_id].avatar_url || 'img/default-profile.png' }}" width="32" height="32" - ng-hide="events.rooms[room_id].messages[$index - 1].user_id === msg.user_id || msg.user_id !== state.user_id"/> + ng-hide="room.events[$index - 1].user_id === msg.user_id || msg.user_id !== state.user_id"/> </td> </tr> </table> |