Implement nicklist
This commit is contained in:
parent
7449a5dcd3
commit
404f8c8cba
4 changed files with 114 additions and 6 deletions
40
js/models.js
40
js/models.js
|
@ -18,6 +18,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
|||
var local_variables = message['local_vars'];
|
||||
var notify = 3 // Default 3 == message
|
||||
var lines = []
|
||||
var nicklist = {}
|
||||
var active = false
|
||||
var notification = 0
|
||||
var unread = 0
|
||||
|
@ -38,6 +39,12 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
|||
lines.push(line);
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds a nick to nicklist
|
||||
*/
|
||||
var addNick = function(nick) {
|
||||
}
|
||||
|
||||
return {
|
||||
id: pointer,
|
||||
fullName: fullName,
|
||||
|
@ -51,6 +58,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
|||
notification: notification,
|
||||
localvars: local_variables,
|
||||
notify: notify,
|
||||
nicklist: nicklist
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -129,7 +137,39 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
|||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Nick class
|
||||
*/
|
||||
this.Nick = function(message) {
|
||||
var prefix = message['prefix'];
|
||||
var visible = message['visible'];
|
||||
var name = message['name'];
|
||||
var prefix_color = message['prefix_color'];
|
||||
var color = message['color'];
|
||||
|
||||
return {
|
||||
prefix: prefix,
|
||||
visible: visible,
|
||||
name: name,
|
||||
prefix_color: prefix_color,
|
||||
color: color
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Nicklist Group class
|
||||
*/
|
||||
this.NickGroup = function(message) {
|
||||
var name = message['name'];
|
||||
var visible = message['visible'];
|
||||
var nicks = [];
|
||||
|
||||
return {
|
||||
name: name,
|
||||
visible: visible,
|
||||
nicks: nicks
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var BufferList = []
|
||||
activeBuffer = null;
|
||||
|
|
|
@ -114,6 +114,47 @@ weechat.factory('handlers', ['$rootScope', 'models', 'plugins', function($rootSc
|
|||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle nicklist event
|
||||
*/
|
||||
var handleNicklist = function(message) {
|
||||
var nicklist = message['objects'][0]['content'];
|
||||
var group = 'root';
|
||||
nicklist.forEach(function(n) {
|
||||
var buffer = models.getBuffer(n.pointers[0]);
|
||||
if(n.group == 1) {
|
||||
var g = new models.NickGroup(n);
|
||||
group = g.name;
|
||||
buffer.nicklist[group] = g;
|
||||
}else{
|
||||
var nick = new models.Nick(n);
|
||||
buffer.nicklist[group].nicks.push(nick);
|
||||
}
|
||||
});
|
||||
}
|
||||
/*
|
||||
* Handle nicklist diff event
|
||||
*/
|
||||
var handleNicklistDiff = function(message) {
|
||||
var nicklist = message['objects'][0]['content'];
|
||||
var group;
|
||||
nicklist.forEach(function(n) {
|
||||
var buffer = models.getBuffer(n.pointers[0]);
|
||||
var d = n['_diff'];
|
||||
if(n.group == 1) {
|
||||
group = buffer.nicklist[n.name];
|
||||
}
|
||||
if(d == 43) { // +
|
||||
var nick = new models.Nick(n);
|
||||
buffer.nicklist[group].nicks.push(nick);
|
||||
}else if (d == 45) { // -
|
||||
var nick = new models.Nick(n);
|
||||
}else if (d == 42) { // *
|
||||
var nick = new models.Nick(n);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var handleEvent = function(event) {
|
||||
|
||||
if (_.has(eventHandlers, event['id'])) {
|
||||
|
@ -127,13 +168,16 @@ weechat.factory('handlers', ['$rootScope', 'models', 'plugins', function($rootSc
|
|||
_buffer_line_added: handleBufferLineAdded,
|
||||
_buffer_opened: handleBufferOpened,
|
||||
_buffer_title_changed: handleBufferTitleChanged,
|
||||
_buffer_renamed: handleBufferRenamed
|
||||
_buffer_renamed: handleBufferRenamed,
|
||||
_nicklist: handleNicklist,
|
||||
_nicklist_diff: handleNicklistDiff
|
||||
}
|
||||
|
||||
return {
|
||||
handleEvent: handleEvent,
|
||||
handleLineInfo: handleLineInfo,
|
||||
handleHotlistInfo: handleHotlistInfo
|
||||
handleHotlistInfo: handleHotlistInfo,
|
||||
handleNicklist: handleNicklist
|
||||
}
|
||||
|
||||
}]);
|
||||
|
@ -237,6 +281,12 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers',
|
|||
})).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({}));
|
||||
$log.info("Synced");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue