New option to sync hotlist with weechat. Fixes #56

This commit is contained in:
Tor Hveem 2013-10-19 12:14:32 +02:00
parent 10480843c2
commit 5712a55620
2 changed files with 35 additions and 1 deletions

View file

@ -162,6 +162,16 @@
</div> </div>
</form> </form>
</li> </li>
<li class="">
<form class="form-inline" role="form">
<div class="checkbox">
<label>
<input type="checkbox" ng-model="hotlistsync">
Sync hotlist with WeeChat
</label>
</div>
</form>
</li>
</ul> </ul>
</div> </div>
<a ng-click="disconnect()"> <a ng-click="disconnect()">

View file

@ -301,12 +301,20 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers',
})); }));
} }
var sendCoreCommand = function(command) {
doSend(weeChat.Protocol.formatInput({
buffer: 'core.weechat',
data: command
}));
}
return { return {
send: doSend, send: doSend,
connect: connect, connect: connect,
disconnect: disconnect, disconnect: disconnect,
sendMessage: sendMessage sendMessage: sendMessage,
sendCoreCommand: sendCoreCommand
} }
}]); }]);
@ -331,6 +339,20 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
document.getElementById('sendMessage').focus(); document.getElementById('sendMessage').focus();
var ab = models.getActiveBuffer(); var ab = models.getActiveBuffer();
$rootScope.pageTitle = ab.shortName + ' | ' + ab.title; $rootScope.pageTitle = ab.shortName + ' | ' + ab.title;
// 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($scope.hotlistsync && ab.fullName) {
/*
doSend(weeChat.Protocol.formatInput({
buffer: 'weechat',
data: '/buffer ' + ab.fullName
}));
*/
connection.sendCoreCommand('/buffer ' + ab.fullName);
}
}); });
$rootScope.$on('notificationChanged', function() { $rootScope.$on('notificationChanged', function() {
var notifications = _.reduce(models.model.buffers, function(memo, num) { return (memo||0) + num.notification;}); var notifications = _.reduce(models.model.buffers, function(memo, num) { return (memo||0) + num.notification;});
@ -373,6 +395,8 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
$store.bind($scope, "onlyUnread", false); $store.bind($scope, "onlyUnread", false);
// Save setting for not showing timestamp // Save setting for not showing timestamp
$store.bind($scope, "notimestamp", false); $store.bind($scope, "notimestamp", false);
// Save setting for syncing hotlist
$store.bind($scope, "hotlistsync", true);
$scope.setActiveBuffer = function(key) { $scope.setActiveBuffer = function(key) {