Open query when clicking nick in the sidebar
This commit is contained in:
parent
706b5838a1
commit
9368f2480d
|
@ -247,7 +247,7 @@ $ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out rel
|
|||
<div id="nicklist" ng-show="showNicklist" class="vertical-line-left">
|
||||
<ul class="nicklistgroup list-unstyled" ng-repeat="group in activeBuffer().nicklist">
|
||||
<li class="" ng-repeat="nick in group.nicks|orderBy:'name'">
|
||||
<a ng-click="nickAction(nick)"><span ng-class="nick.prefixClasses">{{nick.prefix}}</span><span ng-class="nick.nameClasses">{{nick.name}}</span></a>
|
||||
<a ng-click="nickAction(nick)"><span ng-class="nick.prefixClasses">{{nick.prefix}}</span><span ng-class="nick.nameClasses" ng-click="openQuery(nick.name)">{{nick.name}}</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
26
js/models.js
26
js/models.js
|
@ -323,12 +323,27 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
|||
* Deactivates the previous current buffer.
|
||||
*
|
||||
* @param bufferId id of the new active buffer
|
||||
* @return undefined
|
||||
* @return true on success, false if buffer was not found
|
||||
*/
|
||||
this.setActiveBuffer = function(bufferId) {
|
||||
this.setActiveBuffer = function(bufferId, key) {
|
||||
if (typeof(key) === 'undefined') {
|
||||
key = 'id';
|
||||
}
|
||||
|
||||
var previousBuffer = this.getActiveBuffer();
|
||||
|
||||
activeBuffer = _.find(this.model['buffers'], function(buffer) {
|
||||
if (buffer[key] == bufferId) {
|
||||
return buffer;
|
||||
}
|
||||
});
|
||||
|
||||
if (typeof(activeBuffer) === 'undefined') {
|
||||
// Buffer not found, undo assignment
|
||||
activeBuffer = previousBuffer;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (previousBuffer) {
|
||||
// turn off the active status for the previous buffer
|
||||
previousBuffer.active = false;
|
||||
|
@ -336,18 +351,13 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
|||
previousBuffer.lastSeen = previousBuffer.lines.length-1;
|
||||
}
|
||||
|
||||
activeBuffer = _.find(this.model['buffers'], function(buffer) {
|
||||
if (buffer['id'] == bufferId) {
|
||||
return buffer;
|
||||
}
|
||||
});
|
||||
|
||||
activeBuffer.active = true;
|
||||
activeBuffer.unread = 0;
|
||||
activeBuffer.notification = 0;
|
||||
|
||||
$rootScope.$emit('activeBufferChanged');
|
||||
$rootScope.$emit('notificationChanged');
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -63,6 +63,11 @@ weechat.factory('handlers', ['$rootScope', 'models', 'plugins', function($rootSc
|
|||
var bufferMessage = message['objects'][0]['content'][0];
|
||||
var buffer = new models.Buffer(bufferMessage);
|
||||
models.addBuffer(buffer);
|
||||
if ($rootScope.waitForQueryWindow === buffer.fullName) {
|
||||
// We're waiting for a query window
|
||||
models.setActiveBuffer(buffer.id);
|
||||
$rootScope.waitForQueryWindow = "";
|
||||
}
|
||||
}
|
||||
|
||||
var handleBufferTitleChanged = function(message) {
|
||||
|
@ -540,10 +545,20 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
|||
|
||||
$rootScope.predicate = $scope.orderbyserver ? 'serverSortKey' : 'number';
|
||||
|
||||
$scope.setActiveBuffer = function(key) {
|
||||
models.setActiveBuffer(key);
|
||||
$scope.setActiveBuffer = function(bufferId, key) {
|
||||
return models.setActiveBuffer(bufferId, key);
|
||||
};
|
||||
|
||||
$scope.openQuery = function(nick) {
|
||||
var buffName = models.getActiveBuffer()['fullName'];
|
||||
buffName = buffName.substring(0, buffName.lastIndexOf('.')) + '.' + nick;
|
||||
|
||||
if (!$scope.setActiveBuffer(buffName, 'fullName')) {
|
||||
$rootScope.waitForQueryWindow = buffName;
|
||||
connection.sendMessage('/query ' + nick);
|
||||
}
|
||||
}
|
||||
|
||||
$rootScope.scrollToBottom = function() {
|
||||
// FIXME doesn't work if the settimeout runs without a short delay
|
||||
var scroll = function() {
|
||||
|
|
Loading…
Reference in New Issue