From feaf76f1ead845e555958efb19fafe3408e68325 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Mon, 23 Mar 2015 12:58:56 +0100 Subject: [PATCH 1/2] move hotlistclear into connection Also some clean up stray debug --- js/connection.js | 13 +++++++++++++ js/glowingbear.js | 11 +---------- js/handlers.js | 1 - 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/js/connection.js b/js/connection.js index 7844547..48d5cab 100644 --- a/js/connection.js +++ b/js/connection.js @@ -258,6 +258,18 @@ weechat.factory('connection', })); }; + var sendHotlistClear = function() { + if (parseInt(models.version.charAt(0)) >= 1) { + // WeeChat >= 1 supports clearing hotlist with this command + 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 + sendCoreCommand('/buffer ' + models.getActiveBuffer().fullName); + } + }; var requestNicklist = function(bufferId, callback) { bufferId = bufferId || null; @@ -334,6 +346,7 @@ weechat.factory('connection', disconnect: disconnect, sendMessage: sendMessage, sendCoreCommand: sendCoreCommand, + sendHotlistClear: sendHotlistClear, fetchMoreLines: fetchMoreLines, requestNicklist: requestNicklist, attemptReconnect: attemptReconnect diff --git a/js/glowingbear.js b/js/glowingbear.js index ecd5a19..0ed3764 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -228,16 +228,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', // 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); - } + connection.sendHotlistClear(); } }); diff --git a/js/handlers.js b/js/handlers.js index 93dd296..d5dded7 100644 --- a/js/handlers.js +++ b/js/handlers.js @@ -6,7 +6,6 @@ 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 From 9432004c5e0db0424c259338b510f7d1075f9551 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Mon, 23 Mar 2015 13:32:02 +0100 Subject: [PATCH 2/2] Clear hotlist in more scenarios * Clear when switching away from a buffer * Clear when sending a message to a buffer --- js/glowingbear.js | 5 +++++ js/inputbar.js | 3 +++ 2 files changed, 8 insertions(+) diff --git a/js/glowingbear.js b/js/glowingbear.js index 0ed3764..fa03b2f 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -436,6 +436,11 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', if (utils.isMobileUi()) { $scope.hideSidebar(); } + + // Clear the hotlist for this buffer, because presumable you have read + // the messages in this buffer before you switched to the new one + connection.sendHotlistClear(); + return models.setActiveBuffer(bufferId, key); }; diff --git a/js/inputbar.js b/js/inputbar.js index 6f6daf0..c0ec77e 100644 --- a/js/inputbar.js +++ b/js/inputbar.js @@ -104,6 +104,9 @@ weechat.directive('inputBar', function() { $scope.command = ''; } + // Presumable we are reading the messages if we are sending. + connection.sendHotlistClear(); + $scope.getInputNode().focus(); };