mirror of
https://mau.dev/maunium/synapse.git
synced 2024-08-28 13:11:56 +00:00
Do a smart update of the recents from the events stream rather than hammering initialSync each time
This commit is contained in:
parent
62dfa3c741
commit
b09e531159
@ -25,13 +25,24 @@ angular.module('RecentsController', ['matrixService', 'eventHandlerService'])
|
|||||||
// in order to highlight a specific room in the list
|
// in order to highlight a specific room in the list
|
||||||
$scope.recentsSelectedRoomID;
|
$scope.recentsSelectedRoomID;
|
||||||
|
|
||||||
|
var listenToEventStream = function() {
|
||||||
// Refresh the list on matrix invitation and message event
|
// Refresh the list on matrix invitation and message event
|
||||||
$scope.$on(eventHandlerService.MEMBER_EVENT, function(ngEvent, event, isLive) {
|
$scope.$on(eventHandlerService.MEMBER_EVENT, function(ngEvent, event, isLive) {
|
||||||
refresh();
|
var config = matrixService.config();
|
||||||
|
if (event.state_key === config.user_id && event.content.membership === "invite") {
|
||||||
|
console.log("Invited to room " + event.room_id);
|
||||||
|
// FIXME push membership to top level key to match /im/sync
|
||||||
|
event.membership = event.content.membership;
|
||||||
|
// FIXME bodge a nicer name than the room ID for this invite.
|
||||||
|
event.room_display_name = event.user_id + "'s room";
|
||||||
|
$scope.rooms[event.room_id] = event;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
$scope.$on(eventHandlerService.MSG_EVENT, function(ngEvent, event, isLive) {
|
$scope.$on(eventHandlerService.MSG_EVENT, function(ngEvent, event, isLive) {
|
||||||
refresh();
|
$scope.rooms[event.room_id].lastMsg = event;
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
var refresh = function() {
|
var refresh = function() {
|
||||||
// List all rooms joined or been invited to
|
// List all rooms joined or been invited to
|
||||||
@ -56,6 +67,9 @@ angular.module('RecentsController', ['matrixService', 'eventHandlerService'])
|
|||||||
for (var i = 0; i < presence.length; ++i) {
|
for (var i = 0; i < presence.length; ++i) {
|
||||||
eventHandlerService.handleEvent(presence[i], false);
|
eventHandlerService.handleEvent(presence[i], false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// From now, update recents from the stream
|
||||||
|
listenToEventStream();
|
||||||
},
|
},
|
||||||
function(error) {
|
function(error) {
|
||||||
$scope.feedback = "Failure: " + error.data;
|
$scope.feedback = "Failure: " + error.data;
|
||||||
|
Loading…
Reference in New Issue
Block a user