From da9b7b03688e40c0ed5b14ab0e33fb77b6d8b931 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 8 Sep 2014 13:54:09 -0700 Subject: [PATCH] Added big massive TODOs on a huge design problem with initial sync --- .../components/matrix/event-stream-service.js | 2 ++ webclient/recents/recents-controller.js | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/webclient/components/matrix/event-stream-service.js b/webclient/components/matrix/event-stream-service.js index 4c0091ded..1bc850a8f 100644 --- a/webclient/components/matrix/event-stream-service.js +++ b/webclient/components/matrix/event-stream-service.js @@ -105,6 +105,8 @@ angular.module('eventStreamService', []) var deferred = $q.defer(); // FIXME: We are discarding all the messages. + // XXX FIXME TODO : The discard works because we are doing this all over + // again on EVERY INSTANTIATION of the recents controller. matrixService.initialSync(1, false).then( function(response) { var rooms = response.data.rooms; diff --git a/webclient/recents/recents-controller.js b/webclient/recents/recents-controller.js index fcb203b36..b4762acd1 100644 --- a/webclient/recents/recents-controller.js +++ b/webclient/recents/recents-controller.js @@ -16,6 +16,12 @@ 'use strict'; +// XXX FIXME TODO +// We should NOT be dumping things into $rootScope!!!! We should NOT be +// making any requests here, and should READ what is already in the +// rootScope from the event handler service!!! +// XXX FIXME TODO + angular.module('RecentsController', ['matrixService', 'matrixFilter', 'eventHandlerService']) .controller('RecentsController', ['$rootScope', '$scope', 'matrixService', 'eventHandlerService', function($rootScope, $scope, matrixService, eventHandlerService) { @@ -28,6 +34,11 @@ angular.module('RecentsController', ['matrixService', 'matrixFilter', 'eventHand // in order to highlight a specific room in the list $rootScope.recentsSelectedRoomID; + // XXX FIXME TODO : We should NOT be doing this here, which could be + // repeated for every controller instance. We should be doing this in + // event handler service instead. In additon, this will break if there + // isn't a recents controller visible when the last message comes in :/ + var listenToEventStream = function() { // Refresh the list on matrix invitation and message event $rootScope.$on(eventHandlerService.MEMBER_EVENT, function(ngEvent, event, isLive) { @@ -58,7 +69,13 @@ angular.module('RecentsController', ['matrixService', 'matrixFilter', 'eventHand if ($rootScope.rooms) { return; } - + + // XXX FIXME TODO + // We should NOT be dumping things into $rootScope!!!! We should NOT be + // making any requests here, and should READ what is already in the + // rootScope from the event handler service!!! + // XXX FIXME TODO + $rootScope.rooms = {}; // Use initialSync data to init the recents list