Send all init commands in batch
This commit is contained in:
parent
ec4956a379
commit
8c51ab18d3
|
@ -256,34 +256,43 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers',
|
||||||
compression: 'off'
|
compression: 'off'
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// We are asking for the weechat version here
|
/*
|
||||||
// to avoid two problems :
|
* Send all the initialization commands
|
||||||
// - If the version is below 0.4.2, we will have a bug
|
* and resolve them as a single promise.
|
||||||
// with websocket.
|
*/
|
||||||
// - If the user password is wrong, we will be disconneted
|
doSendAllWithCallback([
|
||||||
// at this step.
|
weeChat.Protocol.formatInfo({
|
||||||
doSendWithCallback(weeChat.Protocol.formatInfo({
|
name: 'version',
|
||||||
name: 'version',
|
}),
|
||||||
})).then(function(message) {
|
|
||||||
// If we have received this message
|
|
||||||
// that means the user password is good.
|
|
||||||
|
|
||||||
// Parse the version info message to retrieve
|
weeChat.Protocol.formatHdata({
|
||||||
// the current weechat version.
|
|
||||||
var version = message['objects'][0]['content']['value'];
|
|
||||||
$rootScope.version = version;
|
|
||||||
$log.info(version);
|
|
||||||
}, function(error) {
|
|
||||||
// If the first command fails, it means that we do not have the
|
|
||||||
// proper password
|
|
||||||
$rootScope.passwordError = true;
|
|
||||||
}).then(function() {
|
|
||||||
doSendWithCallback(weeChat.Protocol.formatHdata({
|
|
||||||
path: 'buffer:gui_buffers(*)',
|
path: 'buffer:gui_buffers(*)',
|
||||||
keys: ['local_variables,notify,number,full_name,short_name,title']
|
keys: ['local_variables,notify,number,full_name,short_name,title']
|
||||||
})).then(function(message) {
|
}),
|
||||||
|
|
||||||
|
weeChat.Protocol.formatHdata({
|
||||||
|
path: "buffer:gui_buffers(*)/own_lines/last_line(-"+storage.get('lines')+")/data",
|
||||||
|
keys: []
|
||||||
|
}),
|
||||||
|
|
||||||
|
weeChat.Protocol.formatHdata({
|
||||||
|
path: "hotlist:gui_hotlist(*)",
|
||||||
|
keys: []
|
||||||
|
}),
|
||||||
|
|
||||||
|
weeChat.Protocol.formatNicklist({
|
||||||
|
})
|
||||||
|
|
||||||
|
]).then(
|
||||||
|
function(messages) {
|
||||||
|
var version = messages[0];
|
||||||
|
var bufinfo = messages[1];
|
||||||
|
var lineinfo = messages[2];
|
||||||
|
var hotlist = messages[3];
|
||||||
|
var nicklist = messages[4];
|
||||||
|
|
||||||
$log.info("Parsing bufinfo");
|
$log.info("Parsing bufinfo");
|
||||||
var bufferInfos = message['objects'][0]['content'];
|
var bufferInfos = bufinfo['objects'][0]['content'];
|
||||||
// buffers objects
|
// buffers objects
|
||||||
for (var i = 0; i < bufferInfos.length ; i++) {
|
for (var i = 0; i < bufferInfos.length ; i++) {
|
||||||
var buffer = new models.Buffer(bufferInfos[i]);
|
var buffer = new models.Buffer(bufferInfos[i]);
|
||||||
|
@ -293,36 +302,26 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers',
|
||||||
models.setActiveBuffer(buffer.id);
|
models.setActiveBuffer(buffer.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).then(function() {
|
|
||||||
$log.info("Parsing lineinfo");
|
handlers.handleLineInfo(lineinfo);
|
||||||
doSendWithCallback(weeChat.Protocol.formatHdata({
|
handlers.handleHotlistInfo(hotlist)
|
||||||
path: "buffer:gui_buffers(*)/own_lines/last_line(-"+storage.get('lines')+")/data",
|
handlers.handleNicklist(nicklist)
|
||||||
keys: []
|
|
||||||
})).then(function(hdata) {
|
|
||||||
handlers.handleLineInfo(hdata);
|
|
||||||
});
|
|
||||||
}).then(function() {
|
|
||||||
$log.info("Requesting hotlist");
|
|
||||||
doSendWithCallback(weeChat.Protocol.formatHdata({
|
|
||||||
path: "hotlist:gui_hotlist(*)",
|
|
||||||
keys: []
|
|
||||||
})).then(function(hdata) {
|
|
||||||
handlers.handleHotlistInfo(hdata)
|
|
||||||
});
|
|
||||||
}).then(function() {
|
|
||||||
$log.info("Requesting nicklist");
|
|
||||||
doSendWithCallback(weeChat.Protocol.formatNicklist({
|
|
||||||
})).then(function(nicklistdata) {
|
|
||||||
handlers.handleNicklist(nicklistdata)
|
|
||||||
});
|
|
||||||
}).then(function() {
|
|
||||||
doSend(weeChat.Protocol.formatSync({}));
|
doSend(weeChat.Protocol.formatSync({}));
|
||||||
$log.info("Synced");
|
$log.info("Synced");
|
||||||
|
|
||||||
// here we are really connected !
|
// here we are really connected !
|
||||||
$rootScope.connected = true;
|
$rootScope.connected = true;
|
||||||
});
|
},
|
||||||
});
|
function(error) {
|
||||||
|
// If the first command fails, it means that we do not have the
|
||||||
|
// proper password
|
||||||
|
$rootScope.passwordError = true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue