diff --git a/js/connection.js b/js/connection.js index 705cc43..7844547 100644 --- a/js/connection.js +++ b/js/connection.js @@ -78,7 +78,8 @@ weechat.factory('connection', // a version command. If it fails, it means the we // did not provide the proper password. _initializeConnection(passwd).then( - function() { + function(version) { + handlers.handleVersionInfo(version); // Connection is successful // Send all the other commands required for initialization _requestBufferInfos().then(function(bufinfo) { diff --git a/js/glowingbear.js b/js/glowingbear.js index 5e8817c..83be41b 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -213,13 +213,6 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $timeout(function() { $rootScope.scrollWithBuffer(true); }); - // If user wants to sync hotlist with weechat - // we will send a /buffer bufferName command every time - // the user switches a buffer. This will ensure that notifications - // are cleared in the buffer the user switches to - if (settings.hotlistsync && ab.fullName) { - connection.sendCoreCommand('/buffer ' + ab.fullName); - } // Clear search term on buffer change $scope.search = ''; @@ -232,6 +225,20 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', document.getElementById('sendMessage').focus(); }, 0); } + + // Do this part last since it's not important for the UI + if (settings.hotlistsync && ab.fullName) { + if (parseInt(models.version.charAt(0)) >= 1) { + // WeeChat >= 1 supports clearing hotlist with this command + connection.sendMessage('/buffer set hotlist -1'); + } else { + // If user wants to sync hotlist with weechat + // we will send a /buffer bufferName command every time + // the user switches a buffer. This will ensure that notifications + // are cleared in the buffer the user switches to + connection.sendCoreCommand('/buffer ' + ab.fullName); + } + } }); $rootScope.favico = new Favico({animation: 'none'}); diff --git a/js/handlers.js b/js/handlers.js index b01757a..93dd296 100644 --- a/js/handlers.js +++ b/js/handlers.js @@ -5,6 +5,14 @@ var weechat = angular.module('weechat'); weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notifications', function($rootScope, $log, models, plugins, notifications) { + var handleVersionInfo = function(message) { + console.log(message.objects[0]); + var content = message.objects[0].content; + var version = content.value; + // Store the WeeChat version in models + models.version = version; + }; + var handleBufferClosing = function(message) { var bufferMessage = message.objects[0].content[0]; var bufferId = bufferMessage.pointers[0]; @@ -260,6 +268,7 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific }; return { + handleVersionInfo: handleVersionInfo, handleEvent: handleEvent, handleLineInfo: handleLineInfo, handleHotlistInfo: handleHotlistInfo, diff --git a/js/models.js b/js/models.js index db27acd..4b7d1c7 100644 --- a/js/models.js +++ b/js/models.js @@ -8,6 +8,9 @@ var models = angular.module('weechatModels', []); models.service('models', ['$rootScope', '$filter', function($rootScope, $filter) { + // WeeChat version + this.version = null; + var parseRichText = function(text) { var textElements = weeChat.Protocol.rawText2Rich(text), typeToClassPrefixFg = {