Defer nicklist loading until buffer is opened
Drastically improves startup time for users with buffers that have thousands of users
This commit is contained in:
parent
739c4de0ef
commit
ac548777fc
1 changed files with 28 additions and 14 deletions
|
@ -275,13 +275,6 @@ function($rootScope,
|
|||
);
|
||||
};
|
||||
|
||||
var _requestNicklist = function() {
|
||||
return ngWebsockets.send(
|
||||
weeChat.Protocol.formatNicklist({
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
var _requestBufferInfos = function() {
|
||||
return ngWebsockets.send(
|
||||
weeChat.Protocol.formatHdata({
|
||||
|
@ -322,10 +315,6 @@ function($rootScope,
|
|||
handlers.handleHotlistInfo(hotlist);
|
||||
});
|
||||
|
||||
_requestNicklist().then(function(nicklist) {
|
||||
handlers.handleNicklist(nicklist);
|
||||
});
|
||||
|
||||
_requestSync();
|
||||
$log.info("Connected to relay");
|
||||
$rootScope.connected = true;
|
||||
|
@ -412,6 +401,22 @@ function($rootScope,
|
|||
}));
|
||||
};
|
||||
|
||||
|
||||
var requestNicklist = function(bufferId, callback) {
|
||||
bufferId = bufferId || null;
|
||||
ngWebsockets.send(
|
||||
weeChat.Protocol.formatNicklist({
|
||||
buffer: bufferId
|
||||
})
|
||||
).then(function(nicklist) {
|
||||
handlers.handleNicklist(nicklist);
|
||||
if (callback !== undefined) {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
var fetchMoreLines = function(numLines) {
|
||||
var buffer = models.getActiveBuffer();
|
||||
// Calculate number of lines to fetch, at least as many as the parameter
|
||||
|
@ -468,7 +473,8 @@ function($rootScope,
|
|||
disconnect: disconnect,
|
||||
sendMessage: sendMessage,
|
||||
sendCoreCommand: sendCoreCommand,
|
||||
fetchMoreLines: fetchMoreLines
|
||||
fetchMoreLines: fetchMoreLines,
|
||||
requestNicklist: requestNicklist
|
||||
};
|
||||
}]);
|
||||
|
||||
|
@ -641,15 +647,23 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
|||
};
|
||||
|
||||
$rootScope.$on('activeBufferChanged', function() {
|
||||
$rootScope.scrollWithBuffer(true);
|
||||
|
||||
var ab = models.getActiveBuffer();
|
||||
|
||||
if (ab.isNicklistEmpty()) {
|
||||
var bufferId = '0x' + ab.id; // WeeChat needs the 0x prefix
|
||||
connection.requestNicklist(bufferId, function() {
|
||||
$scope.showNicklist = $scope.updateShowNicklist();
|
||||
});
|
||||
}
|
||||
|
||||
if (ab.requestedLines < $scope.lines) {
|
||||
// buffer has not been loaded, but some lines may already be present if they arrived after we connected
|
||||
$scope.fetchMoreLines($scope.lines);
|
||||
}
|
||||
$rootScope.updateTitle(ab);
|
||||
|
||||
$rootScope.scrollWithBuffer(true);
|
||||
|
||||
// If user wants to sync hotlist with weechat
|
||||
// we will send a /buffer bufferName command every time
|
||||
// the user switches a buffer. This will ensure that notifications
|
||||
|
|
Loading…
Reference in a new issue