<commit_before>import { Component, Input } from '@angular/core';
import { Http, Headers, URLSearchParams } from "@angular/http";
import { DataService } from '../shared/data.service';
import { animations } from '../shared/animations'

@Component({
  selector: 'tw-timeline',
  templateUrl: './app/components/timeline/timeline.component.html',
  animations: [ animations() ]
})
export class TimelineComponent {
  tweets = [];
  showingRetweet: boolean = true;
  hasFetchedMissedTweets: boolean = false;
  @Input() havingServerError;
  
  constructor(private dataService: DataService) {}

  ngOnInit() {
      this.dataService.socket.on('new tweet', (tweet) => {
            this.hasFetchedMissedTweets = true;
            this.tweets.unshift(tweet); // prepend 
      });

      this.dataService
          .getMissedTweets()
          .subscribe(res => {
            res.json().data.forEach((tweet) => {
                this.tweets.unshift(tweet); // prepend 
            });
            console.log('Just fetched missed tweets.');
      });
  }

  messages = {
      headText: {
        default: 'Here come the new tweets!',
        failure: 'Oops...'
      },
      paraText: {
        default: 'Go tweet with those hashtags and see them here!',
        failure: 'Sorry, but the server is on vacation.' // when this.havingServerError
      }
  }
}
<commit_msg>Enabled maintaining frontend data store<commit_after>import { Component, Input } from '@angular/core';
import { Http, Headers, URLSearchParams } from "@angular/http";
import { DataService } from '../shared/data.service';
import { animations } from '../shared/animations'

@Component({
  selector: 'tw-timeline',
  templateUrl: './app/components/timeline/timeline.component.html',
  animations: [ animations() ]
})
export class TimelineComponent {
  tweets = [];
  showingRetweet: boolean = true;
  hasFetchedMissedTweets: boolean = false;
  numOfCachedTweets : number = 42;
  @Input() havingServerError;
  
  constructor(private dataService: DataService) {}

  ngOnInit() {
      this.dataService.socket.on('new tweet', (tweet) => {
            this.hasFetchedMissedTweets = true;
            if (this.tweets.length > this.numOfCachedTweets) {
              this.tweets = this.tweets.slice(0, this.tweets.length >> 1); // remove the second half
            }
            this.tweets.unshift(tweet); // prepend 
      });

      this.dataService
          .getMissedTweets()
          .subscribe(res => {
            res.json().data.forEach((tweet) => {
                this.tweets.unshift(tweet); // prepend 
            });
            console.log('Just fetched missed tweets.');
      });
  }

  messages = {
      headText: {
        default: 'Here come the new tweets!',
        failure: 'Oops...'
      },
      paraText: {
        default: 'Go tweet with those hashtags and see them here!',
        failure: 'Sorry, but the server is on vacation.' // when this.havingServerError
      }
  }
}

{'fraction_non_alphanumeric': 0.1355187563366002, 'fraction_numerical': 0.0013518080432578573, 'mean_word_length': 2.4946871310507674, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2358006', 'n_tokens_mistral': 908, 'n_tokens_neox': 882, 'n_words': 198}