optimization of the buffer usage

This commit is contained in:
Nicolas Constant 2018-09-17 23:15:54 -04:00
parent 394614e93a
commit e1108e1872
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
1 changed files with 6 additions and 1 deletions

View File

@ -49,6 +49,7 @@ export class StreamComponent implements OnInit {
@ViewChild('statusstream') public statustream: ElementRef;
goToTop(): boolean {
this.loadBuffer();
if (this.statuses.length > 40) {
this.statuses.length = 40;
}
@ -79,13 +80,17 @@ export class StreamComponent implements OnInit {
private scrolledToTop() {
this.streamPositionnedAtTop = true;
this.loadBuffer();
}
private loadBuffer(){
if(this.bufferWasCleared) {
this.statuses.length = 0;
this.bufferWasCleared = false;
}
for (const status of this.bufferStream) {
this.statuses.unshift(status); //TODO check order of status
this.statuses.unshift(status);
}
this.bufferStream.length = 0;