handle initial sync and no notification, use short_name

This commit is contained in:
Tor Hveem 2013-10-06 23:59:34 +02:00
parent 7230e7a3ee
commit 2100fabf24
2 changed files with 17 additions and 13 deletions

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html ng-app="weechat">
<head> <head>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" media="screen"> <link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js" rel="stylesheet" media="screen"> <link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js" rel="stylesheet" media="screen">
@ -11,7 +11,7 @@
<script type="text/javascript" src="js/protocol.js"></script> <script type="text/javascript" src="js/protocol.js"></script>
<script type="text/javascript" src="js/websockets.js"></script> <script type="text/javascript" src="js/websockets.js"></script>
</head> </head>
<body ng-app="weechat"> <body>
<div ng-controller="WeechatCtrl"> <div ng-controller="WeechatCtrl">
<div ng-hide="connected" class="container"> <div ng-hide="connected" class="container">
<h2> <h2>
@ -55,11 +55,11 @@
<ul class="nav nav-pills"> <ul class="nav nav-pills">
<li class="label" ng-class="{'label-success': content.notification }" ng-repeat="(key, content) in buffers | toArray | orderBy:'content.number':true"> <li class="label" ng-class="{'label-success': content.notification }" ng-repeat="(key, content) in buffers | toArray | orderBy:'content.number':true">
<a ng-click="setActiveBuffer(content.id)">{{ content.full_name }}</a> <a ng-click="setActiveBuffer(content.id)" title="{{ content.full_name }}">{{ content.short_name }}</a>
</li> </li>
</ul> </ul>
<div class="bufferlines" ng-repeat="bufferline in activeBuffer.lines"> <div class="bufferlines" ng-repeat="bufferline in activeBuffer.lines">
<span class="date muted"> <span class="date text-muted">
{{ bufferline.date }} {{ bufferline.date }}
</span> </span>

View File

@ -272,7 +272,7 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($
$rootScope.closeBuffer(buffer_pointer); $rootScope.closeBuffer(buffer_pointer);
} }
var handleLine = function(line) { var handleLine = function(line, initial) {
var buffer_line = {} var buffer_line = {}
var date = line['date']; var date = line['date'];
date = new Date(parseInt(date, 10) * 1000); date = new Date(parseInt(date, 10) * 1000);
@ -295,7 +295,7 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($
buffer_line['message'] = message; buffer_line['message'] = message;
if (!_isActiveBuffer(buffer)) { if (!_isActiveBuffer(buffer) && !initial) {
$rootScope.buffers[buffer]['notification'] = true; $rootScope.buffers[buffer]['notification'] = true;
} }
@ -311,7 +311,7 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($
buffer_line['date'] = datestring; buffer_line['date'] = datestring;
if(highlight || _.contains(tags_array, 'notify_private')) { if(!initial && (highlight || _.contains(tags_array, 'notify_private')) ) {
$rootScope.createHighlight(prefix, text, message, buffer, additionalContent); $rootScope.createHighlight(prefix, text, message, buffer, additionalContent);
} }
} }
@ -319,7 +319,7 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($
var handleBufferLineAdded = function(message) { var handleBufferLineAdded = function(message) {
message['objects'][0]['content'].forEach(function(l) { message['objects'][0]['content'].forEach(function(l) {
handleLine(l); handleLine(l, false);
}); });
} }
@ -335,9 +335,13 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($
} }
var handleBufferOpened = function(message) { var handleBufferOpened = function(message) {
var fullName = message['objects'][0]['content'][0]['full_name'] var obj = message['objects'][0]['content'][0];
var buffer = message['objects'][0]['content'][0]['pointers'][0] var fullName = obj['full_name'];
$rootScope.buffers[buffer] = { 'id': buffer, 'lines':[], 'full_name':fullName } var buffer = obj['pointers'][0];
var short_name = obj['short_name'];
var title = obj['title'];
$rootScope.buffers[buffer] = { 'id': buffer, 'lines':[], 'full_name':fullName, 'short_name':short_name, 'title':title }
} }
@ -379,7 +383,7 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($
var handleLineInfo = function(message) { var handleLineInfo = function(message) {
var lines = message['objects'][0]['content'].reverse(); var lines = message['objects'][0]['content'].reverse();
lines.forEach(function(l) { lines.forEach(function(l) {
handleLine(l); handleLine(l, true);
}); });
} }
@ -442,7 +446,7 @@ weechat.factory('connection', ['$rootScope', '$log', 'handlers', 'colors', funct
send += "init compression=off,password=" + password + "\n"; send += "init compression=off,password=" + password + "\n";
} }
send += "(bufinfo) hdata buffer:gui_buffers(*) number,full_name\n"; send += "(bufinfo) hdata buffer:gui_buffers(*) number,full_name,short_name,title\n";
send += "sync\n"; send += "sync\n";
} else { } else {