Merge pull request #565 from glowing-bear/improve-hotlistsync
Use new command for "syncing" hotlist.
This commit is contained in:
commit
fe3360df15
4 changed files with 28 additions and 8 deletions
|
@ -78,7 +78,8 @@ weechat.factory('connection',
|
||||||
// a version command. If it fails, it means the we
|
// a version command. If it fails, it means the we
|
||||||
// did not provide the proper password.
|
// did not provide the proper password.
|
||||||
_initializeConnection(passwd).then(
|
_initializeConnection(passwd).then(
|
||||||
function() {
|
function(version) {
|
||||||
|
handlers.handleVersionInfo(version);
|
||||||
// Connection is successful
|
// Connection is successful
|
||||||
// Send all the other commands required for initialization
|
// Send all the other commands required for initialization
|
||||||
_requestBufferInfos().then(function(bufinfo) {
|
_requestBufferInfos().then(function(bufinfo) {
|
||||||
|
|
|
@ -213,13 +213,6 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$rootScope.scrollWithBuffer(true);
|
$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
|
// Clear search term on buffer change
|
||||||
$scope.search = '';
|
$scope.search = '';
|
||||||
|
@ -232,6 +225,20 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
document.getElementById('sendMessage').focus();
|
document.getElementById('sendMessage').focus();
|
||||||
}, 0);
|
}, 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'});
|
$rootScope.favico = new Favico({animation: 'none'});
|
||||||
|
|
|
@ -5,6 +5,14 @@ var weechat = angular.module('weechat');
|
||||||
|
|
||||||
weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notifications', function($rootScope, $log, models, plugins, notifications) {
|
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 handleBufferClosing = function(message) {
|
||||||
var bufferMessage = message.objects[0].content[0];
|
var bufferMessage = message.objects[0].content[0];
|
||||||
var bufferId = bufferMessage.pointers[0];
|
var bufferId = bufferMessage.pointers[0];
|
||||||
|
@ -260,6 +268,7 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
handleVersionInfo: handleVersionInfo,
|
||||||
handleEvent: handleEvent,
|
handleEvent: handleEvent,
|
||||||
handleLineInfo: handleLineInfo,
|
handleLineInfo: handleLineInfo,
|
||||||
handleHotlistInfo: handleHotlistInfo,
|
handleHotlistInfo: handleHotlistInfo,
|
||||||
|
|
|
@ -8,6 +8,9 @@
|
||||||
var models = angular.module('weechatModels', []);
|
var models = angular.module('weechatModels', []);
|
||||||
|
|
||||||
models.service('models', ['$rootScope', '$filter', function($rootScope, $filter) {
|
models.service('models', ['$rootScope', '$filter', function($rootScope, $filter) {
|
||||||
|
// WeeChat version
|
||||||
|
this.version = null;
|
||||||
|
|
||||||
var parseRichText = function(text) {
|
var parseRichText = function(text) {
|
||||||
var textElements = weeChat.Protocol.rawText2Rich(text),
|
var textElements = weeChat.Protocol.rawText2Rich(text),
|
||||||
typeToClassPrefixFg = {
|
typeToClassPrefixFg = {
|
||||||
|
|
Loading…
Add table
Reference in a new issue