From 8c965e0b90fa89a9f41edf07015a88a583159dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Sat, 6 Jun 2015 16:53:38 +0200 Subject: [PATCH 1/4] Store WeeChat version is an array of numbers --- js/connection.js | 2 +- js/glowingbear.js | 2 +- js/handlers.js | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/js/connection.js b/js/connection.js index 9f9b345..7f561e7 100644 --- a/js/connection.js +++ b/js/connection.js @@ -267,7 +267,7 @@ weechat.factory('connection', }; var sendHotlistClear = function() { - if (parseInt(models.version.charAt(0)) >= 1) { + if (models.version[0] >= 1) { // WeeChat >= 1 supports clearing hotlist with this command sendMessage('/buffer set hotlist -1'); // Also move read marker diff --git a/js/glowingbear.js b/js/glowingbear.js index 8e2d642..eab3edd 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -447,7 +447,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', // the messages in this buffer before you switched to the new one // this is only needed with new type of clearing since in the old // way WeeChat itself takes care of that part - if (parseInt(models.version.charAt(0)) >= 1) { + if (models.version[0] >= 1) { connection.sendHotlistClear(); } diff --git a/js/handlers.js b/js/handlers.js index deb88d3..4af68d5 100644 --- a/js/handlers.js +++ b/js/handlers.js @@ -9,7 +9,8 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific var content = message.objects[0].content; var version = content.value; // Store the WeeChat version in models - models.version = version; + // this eats things like 1.3-dev -> [1,3] + models.version = version.split(".").map(function(c) { return parseInt(c); }); }; var handleBufferClosing = function(message) { From 2626b5e936b42326808327e70f7a0c004f0ed38d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Sat, 6 Jun 2015 16:55:49 +0200 Subject: [PATCH 2/4] openBuffer: send /join and /query with -noswitch parameter this functionality is currently broken (#618) but this is a good idea nonetheless --- js/glowingbear.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index eab3edd..609de7c 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -459,9 +459,17 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', fullName = fullName.substring(0, fullName.lastIndexOf('.') + 1) + bufferName; // substitute the last part if (!$scope.setActiveBuffer(fullName, 'fullName')) { - var command = 'join'; + // WeeChat 0.4.0+ supports /join -noswitch + // As Glowing Bear requires 0.4.2+, we don't need to check the version + var command = 'join -noswitch'; + + // Check if it's a query and we need to use /query instead if (['#', '&', '+', '!'].indexOf(bufferName.charAt(0)) < 0) { // these are the characters a channel name can start with (RFC 2813-2813) command = 'query'; + // WeeChat 1.2+ supports /query -noswitch. See also #577 (different context) + if ((models.version[0] == 1 && models.version[1] >= 2) || models.version[1] > 1) { + command += " -noswitch"; + } } connection.sendMessage('/' + command + ' ' + bufferName); } From 1f89a0ef0bc4d7e9434b215caa620152513b36be Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Wed, 10 Jun 2015 10:03:48 +0200 Subject: [PATCH 3/4] Use new version check --- js/models.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/models.js b/js/models.js index efc93d0..84b223d 100644 --- a/js/models.js +++ b/js/models.js @@ -461,7 +461,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter) * @return active buffer pointer (WeeChat 1.0+) or fullname (older versions) */ this.getActiveBufferReference = function() { - if (this.version !== null && parseInt(this.version.charAt(0)) >= 1) { + if (this.version !== null && this.version[0] >= 1) { // pointers are being validated, they're more reliable than // fullName (e.g. if fullName contains spaces) return "0x"+activeBuffer.id; From 1f37f848fca214d65b491184b43f7f215a58726d Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Thu, 17 Sep 2015 08:59:38 +0200 Subject: [PATCH 4/4] fix another version check --- js/inputbar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/inputbar.js b/js/inputbar.js index 8553c07..701b4b9 100644 --- a/js/inputbar.js +++ b/js/inputbar.js @@ -118,7 +118,7 @@ weechat.directive('inputBar', function() { } // New style clearing requires this, old does not - if (parseInt(models.version.charAt(0)) >= 1) { + if (models.version[0] >= 1) { connection.sendHotlistClear(); }