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() {
|
var _requestBufferInfos = function() {
|
||||||
return ngWebsockets.send(
|
return ngWebsockets.send(
|
||||||
weeChat.Protocol.formatHdata({
|
weeChat.Protocol.formatHdata({
|
||||||
|
@ -322,10 +315,6 @@ function($rootScope,
|
||||||
handlers.handleHotlistInfo(hotlist);
|
handlers.handleHotlistInfo(hotlist);
|
||||||
});
|
});
|
||||||
|
|
||||||
_requestNicklist().then(function(nicklist) {
|
|
||||||
handlers.handleNicklist(nicklist);
|
|
||||||
});
|
|
||||||
|
|
||||||
_requestSync();
|
_requestSync();
|
||||||
$log.info("Connected to relay");
|
$log.info("Connected to relay");
|
||||||
$rootScope.connected = true;
|
$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 fetchMoreLines = function(numLines) {
|
||||||
var buffer = models.getActiveBuffer();
|
var buffer = models.getActiveBuffer();
|
||||||
// Calculate number of lines to fetch, at least as many as the parameter
|
// Calculate number of lines to fetch, at least as many as the parameter
|
||||||
|
@ -468,7 +473,8 @@ function($rootScope,
|
||||||
disconnect: disconnect,
|
disconnect: disconnect,
|
||||||
sendMessage: sendMessage,
|
sendMessage: sendMessage,
|
||||||
sendCoreCommand: sendCoreCommand,
|
sendCoreCommand: sendCoreCommand,
|
||||||
fetchMoreLines: fetchMoreLines
|
fetchMoreLines: fetchMoreLines,
|
||||||
|
requestNicklist: requestNicklist
|
||||||
};
|
};
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
@ -641,15 +647,23 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
};
|
};
|
||||||
|
|
||||||
$rootScope.$on('activeBufferChanged', function() {
|
$rootScope.$on('activeBufferChanged', function() {
|
||||||
$rootScope.scrollWithBuffer(true);
|
|
||||||
|
|
||||||
var ab = models.getActiveBuffer();
|
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) {
|
if (ab.requestedLines < $scope.lines) {
|
||||||
// buffer has not been loaded, but some lines may already be present if they arrived after we connected
|
// buffer has not been loaded, but some lines may already be present if they arrived after we connected
|
||||||
$scope.fetchMoreLines($scope.lines);
|
$scope.fetchMoreLines($scope.lines);
|
||||||
}
|
}
|
||||||
$rootScope.updateTitle(ab);
|
$rootScope.updateTitle(ab);
|
||||||
|
|
||||||
|
$rootScope.scrollWithBuffer(true);
|
||||||
|
|
||||||
// If user wants to sync hotlist with weechat
|
// If user wants to sync hotlist with weechat
|
||||||
// we will send a /buffer bufferName command every time
|
// we will send a /buffer bufferName command every time
|
||||||
// the user switches a buffer. This will ensure that notifications
|
// the user switches a buffer. This will ensure that notifications
|
||||||
|
|
Loading…
Reference in a new issue