Handle lineinfo with callback

This commit is contained in:
David Cormier 2013-10-12 12:29:10 -04:00
parent 9668b65f7a
commit 5cf635bc70

View file

@ -286,8 +286,8 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'models', 'plugins', functi
} }
return { return {
handleEvent: handleEvent handleEvent: handleEvent,
handleLineInfo: handleLineInfo
} }
}]); }]);
@ -369,7 +369,7 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', 'handlers', 'colors',
message = protocol.parse(evt.data) message = protocol.parse(evt.data)
if (_.has(callbacks, message['id'])) { if (_.has(callbacks, message['id'])) {
var promise = callbacks[message['id']]; var promise = callbacks[message['id']];
promise.cb.resolve(message.data); promise.cb.resolve(message);
delete(callbacks[message['id']]); delete(callbacks[message['id']]);
} else { } else {
handlers.handleEvent(message); handlers.handleEvent(message);
@ -396,11 +396,13 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', 'handlers', 'colors',
} }
var getLines = function(count) { var getLines = function(count) {
doSend(WeeChatProtocol.formatHdata({ doSendWithCallback(WeeChatProtocol.formatHdata({
id: 'lineinfo',
path: "buffer:gui_buffers(*)/own_lines/last_line(-"+count+")/data", path: "buffer:gui_buffers(*)/own_lines/last_line(-"+count+")/data",
keys: [] keys: []
})); })).then(function(hdata) {
console.log(hdata);
handlers.handleLineInfo(hdata);
});
} }
return { return {