implement last read marker
This commit is contained in:
parent
c3ce6b3da8
commit
ee890222c5
|
@ -24,6 +24,9 @@ input#sendMessage {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
td.time {
|
td.time {
|
||||||
padding-right: 5px;
|
padding-right: 5px;
|
||||||
}
|
}
|
||||||
|
@ -35,6 +38,11 @@ td.prefix {
|
||||||
}
|
}
|
||||||
td.message {
|
td.message {
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
#readmarker {
|
||||||
|
margin: 0;
|
||||||
|
color: #111;
|
||||||
}
|
}
|
||||||
.text {
|
.text {
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
|
|
|
@ -109,7 +109,7 @@ $ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out rel
|
||||||
<div class="bufferlines">
|
<div class="bufferlines">
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr class="bufferline" ng-repeat="bufferline in activeBuffer().lines">
|
<tr class="bufferline" ng-repeat-start="bufferline in activeBuffer().lines">
|
||||||
<td class="time">
|
<td class="time">
|
||||||
<span class="date text-muted">
|
<span class="date text-muted">
|
||||||
{{ bufferline.date | date:'HH:mm' }}
|
{{ bufferline.date | date:'HH:mm' }}
|
||||||
|
@ -133,6 +133,11 @@ $ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out rel
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr ng-repeat-end ng-if="activeBuffer().lastSeen-1==$index">
|
||||||
|
<td colspan="3">
|
||||||
|
<hr id="readmarker">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
14
js/models.js
14
js/models.js
|
@ -19,6 +19,7 @@ models.service('models', ['colors', function(colors) {
|
||||||
var active = false;
|
var active = false;
|
||||||
var notification = false;
|
var notification = false;
|
||||||
var unread = '';
|
var unread = '';
|
||||||
|
var lastSeen = -2;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Adds a line to this buffer
|
* Adds a line to this buffer
|
||||||
|
@ -37,7 +38,8 @@ models.service('models', ['colors', function(colors) {
|
||||||
number: number,
|
number: number,
|
||||||
title: title,
|
title: title,
|
||||||
lines: lines,
|
lines: lines,
|
||||||
addLine: addLine
|
addLine: addLine,
|
||||||
|
lastSeen: lastSeen,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -144,8 +146,13 @@ models.service('models', ['colors', function(colors) {
|
||||||
*/
|
*/
|
||||||
this.setActiveBuffer = function(bufferId) {
|
this.setActiveBuffer = function(bufferId) {
|
||||||
|
|
||||||
if (this.getActiveBuffer()) {
|
var previousBuffer = this.getActiveBuffer();
|
||||||
this.getActiveBuffer().active = false;
|
|
||||||
|
if (previousBuffer) {
|
||||||
|
// turn off the active status for the previous buffer
|
||||||
|
previousBuffer.active = false;
|
||||||
|
// Save the last line we saw
|
||||||
|
previousBuffer.lastSeen = previousBuffer.lines.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
activeBuffer = _.find(this.model['buffers'], function(buffer) {
|
activeBuffer = _.find(this.model['buffers'], function(buffer) {
|
||||||
|
@ -156,7 +163,6 @@ models.service('models', ['colors', function(colors) {
|
||||||
activeBuffer.notification = false;
|
activeBuffer.notification = false;
|
||||||
activeBuffer.active = true;
|
activeBuffer.active = true;
|
||||||
activeBuffer.unread = '';
|
activeBuffer.unread = '';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -451,26 +451,22 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
|
|
||||||
$scope.setActiveBuffer = function(key) {
|
$scope.setActiveBuffer = function(key) {
|
||||||
models.setActiveBuffer(key);
|
models.setActiveBuffer(key);
|
||||||
|
$rootScope.scrollToBottom();
|
||||||
|
document.getElementById('sendMessage').focus();
|
||||||
var ab = models.getActiveBuffer();
|
var ab = models.getActiveBuffer();
|
||||||
$rootScope.pageTitle = ab.shortName + ' | ' + ab.title;
|
$rootScope.pageTitle = ab.shortName + ' | ' + ab.title;
|
||||||
document.getElementById('sendMessage').focus();
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.$watch('models.getActiveBuffer()', function(newVal, oldVal) {
|
|
||||||
if (newVal && newVal !== oldVal) {
|
|
||||||
$rootScope.scrollToBottom();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$rootScope.scrollToBottom = function() {
|
$rootScope.scrollToBottom = function() {
|
||||||
// FIXME doesn't work if the settimeout runs without a short delay
|
// FIXME doesn't work if the settimeout runs without a short delay
|
||||||
// 300 ms seems to do the trick but creates a noticable flickr
|
// 300 ms seems to do the trick but creates a noticable flickr
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
// TODO in the future, implement scrolling to last read line
|
var readmarker = document.getElementById('readmarker');
|
||||||
var lastline = document.querySelector('.bufferline:last-child');
|
if(readmarker) {
|
||||||
if(lastline) {
|
readmarker.scrollIntoView();
|
||||||
window.scrollTo(0, lastline.offsetTop);
|
}else{
|
||||||
|
window.scroll(0, window.scrollMaxY);
|
||||||
}
|
}
|
||||||
}, 300);
|
}, 300);
|
||||||
}
|
}
|
||||||
|
@ -553,12 +549,13 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
|
|
||||||
// Handle alt-a
|
// Handle alt-a
|
||||||
if($event.altKey && (code == 97 || code == 65)) {
|
if($event.altKey && (code == 97 || code == 65)) {
|
||||||
|
$event.preventDefault();
|
||||||
$rootScope.switchToActivityBuffer();
|
$rootScope.switchToActivityBuffer();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Handle ctrl-g
|
// Handle ctrl-g
|
||||||
if($event.ctrlKey && (code == 103 || code == 71)) {
|
if($event.ctrlKey && (code == 103 || code == 71)) {
|
||||||
document.querySelector('#bufferFilter').focus();
|
document.getElementById('bufferFilter').focus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue