Handle hidden weechat buffers

This adds a new 'hidden' field to the Buffer model, which stays in sync
with weechat's notion of hidden buffers.
This commit is contained in:
Angus Gibson 2015-07-10 13:52:12 +10:00
parent d07ba4edd1
commit 117d9991ec
4 changed files with 22 additions and 3 deletions

View File

@ -62,7 +62,7 @@ weechat.factory('connection',
return ngWebsockets.send( return ngWebsockets.send(
weeChat.Protocol.formatHdata({ 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,hidden']
}) })
); );
}; };

View File

@ -654,9 +654,9 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
if (buffer.fullName === "core.weechat") { if (buffer.fullName === "core.weechat") {
return true; return true;
} }
return buffer.unread > 0 || buffer.notification > 0; return (buffer.unread > 0 || buffer.notification > 0) && !buffer.hidden;
} }
return true; return !buffer.hidden;
}; };
// Watch model and update show setting when it changes // Watch model and update show setting when it changes

View File

@ -81,6 +81,7 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific
buffer.trimmedName = buffer.shortName.replace(/^[#&+]/, ''); buffer.trimmedName = buffer.shortName.replace(/^[#&+]/, '');
buffer.title = message.title; buffer.title = message.title;
buffer.number = message.number; buffer.number = message.number;
buffer.hidden = message.hidden;
// reset these, hotlist info will arrive shortly // reset these, hotlist info will arrive shortly
buffer.notification = 0; buffer.notification = 0;
@ -145,6 +146,20 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific
} }
}; };
var handleBufferHidden = function(message) {
var obj = message.objects[0].content[0];
var buffer = obj.pointers[0];
var old = models.getBuffer(buffer);
old.hidden = true;
};
var handleBufferUnhidden = function(message) {
var obj = message.objects[0].content[0];
var buffer = obj.pointers[0];
var old = models.getBuffer(buffer);
old.hidden = false;
};
var handleBufferLocalvarChanged = function(message) { var handleBufferLocalvarChanged = function(message) {
var obj = message.objects[0].content[0]; var obj = message.objects[0].content[0];
var buffer = obj.pointers[0]; var buffer = obj.pointers[0];
@ -253,6 +268,8 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific
_buffer_opened: handleBufferOpened, _buffer_opened: handleBufferOpened,
_buffer_title_changed: handleBufferTitleChanged, _buffer_title_changed: handleBufferTitleChanged,
_buffer_renamed: handleBufferRenamed, _buffer_renamed: handleBufferRenamed,
_buffer_hidden: handleBufferHidden,
_buffer_unhidden: handleBufferUnhidden,
_nicklist: handleNicklist, _nicklist: handleNicklist,
_nicklist_diff: handleNicklistDiff _nicklist_diff: handleNicklistDiff
}; };

View File

@ -63,6 +63,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
// weechat properties // weechat properties
var fullName = message.full_name; var fullName = message.full_name;
var shortName = message.short_name; var shortName = message.short_name;
var hidden = message.hidden;
// If it's a channel, trim away the prefix (#, &, or +). If that is empty and the buffer // If it's a channel, trim away the prefix (#, &, or +). If that is empty and the buffer
// has a short name, use a space (because the prefix will be displayed separately, and we don't want // has a short name, use a space (because the prefix will be displayed separately, and we don't want
// prefix + fullname, which would happen otherwise). Else, use null so that full_name is used // prefix + fullname, which would happen otherwise). Else, use null so that full_name is used
@ -289,6 +290,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
id: pointer, id: pointer,
fullName: fullName, fullName: fullName,
shortName: shortName, shortName: shortName,
hidden: hidden,
trimmedName: trimmedName, trimmedName: trimmedName,
prefix: prefix, prefix: prefix,
number: number, number: number,