<commit_before>import { Component, Input, ViewChild } from '@angular/core';

import { GroupsService } from '../../groups-service';

import { Client } from '../../../../services/api';
import { SessionFactory } from '../../../../services/session';
import { Poster } from '../../../legacy/controllers/newsfeed/poster/poster';

interface MindsGroupResponse {
  group: MindsGroup;
}
interface MindsGroup {
  guid: string;
  name: string;
  banner: boolean;
  members: Array<any>;
}

@Component({
  moduleId: module.id,
  selector: 'minds-groups-profile-feed',
  templateUrl: 'feed.html'
})

export class GroupsProfileFeed {

  guid;
  group: any;

  filter: 'activity' | 'review' = 'activity';

  session = SessionFactory.build();

  activity: Array<any> = [];
  offset: string = '';
  inProgress: boolean = false;
  moreData: boolean = true;

  pollingTimer: any;
  pollingOffset: string = '';
  pollingNewPosts: number = 0;

  kickPrompt: boolean = false;
  kickBan: boolean = false;
  kickSuccess: boolean = false;
  kickUser: any;

  @ViewChild('poster') private poster: Poster;

  constructor(public client: Client, public service: GroupsService) { }

  @Input('group') set _group(value: any) {
    this.group = value;
    this.guid = value.guid;
    this.load(true);
    this.setUpPoll();
  }

  @Input('filter') set _filter(value: 'activity' | 'review') {
    const oldFilter = this.filter;
    this.filter = value;

    if (this.group && oldFilter != this.filter) {
      this.load(true);
    }
  }

  setUpPoll() {
    this.pollingTimer = setInterval(() => {
      this.client.get('api/v1/newsfeed/container/' + this.guid, { offset: this.pollingOffset, count: true }, { cache: true })
        .then((response: any) => {
          if (typeof response.count === 'undefined') {
            return;
          }

          this.pollingNewPosts += response.count;
          this.pollingOffset = response['load-next'];
        })
        .catch(e => { console.error('Newsfeed polling', e); });
    }, 60000);
  }

  pollingLoadNew() {
    this.load(true);
  }

  ngOnDestroy() {
    clearInterval(this.pollingTimer);
  }<commit_msg>(fix) Offset polling undefined (#348)<commit_after>import { Component, Input, ViewChild } from '@angular/core';

import { GroupsService } from '../../groups-service';

import { Client } from '../../../../services/api';
import { SessionFactory } from '../../../../services/session';
import { Poster } from '../../../legacy/controllers/newsfeed/poster/poster';

interface MindsGroupResponse {
  group: MindsGroup;
}
interface MindsGroup {
  guid: string;
  name: string;
  banner: boolean;
  members: Array<any>;
}

@Component({
  moduleId: module.id,
  selector: 'minds-groups-profile-feed',
  templateUrl: 'feed.html'
})

export class GroupsProfileFeed {

  guid;
  group: any;

  filter: 'activity' | 'review' = 'activity';

  session = SessionFactory.build();

  activity: Array<any> = [];
  offset: string = '';
  inProgress: boolean = false;
  moreData: boolean = true;

  pollingTimer: any;
  pollingOffset: string = '';
  pollingNewPosts: number = 0;

  kickPrompt: boolean = false;
  kickBan: boolean = false;
  kickSuccess: boolean = false;
  kickUser: any;

  @ViewChild('poster') private poster: Poster;

  constructor(public client: Client, public service: GroupsService) { }

  @Input('group') set _group(value: any) {
    this.group = value;
    this.guid = value.guid;
    this.load(true);
    this.setUpPoll();
  }

  @Input('filter') set _filter(value: 'activity' | 'review') {
    const oldFilter = this.filter;
    this.filter = value;

    if (this.group && oldFilter != this.filter) {
      this.load(true);
    }
  }

  setUpPoll() {
    this.pollingTimer = setInterval(() => {
      this.client.get('api/v1/newsfeed/container/' + this.guid, { offset: this.pollingOffset, count: true }, { cache: true })
        .then((response: any) => {
          if (typeof response.count === 'undefined') {
            return;
          }

          this.pollingNewPosts += response.count;
          this.pollingOffset = response['load-previous'];
        })
        .catch(e => { console.error('Newsfeed polling', e); });
    }, 60000);
  }

  pollingLoadNew() {
    this.load(true);
  }

  ngOnDestroy() {
    clearInterval(this.pollingTimer);
  }
{'fraction_non_alphanumeric': 0.16402239850676623, 'fraction_numerical': 0.003966402239850677, 'mean_word_length': 3.0405278039585295, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '2224022', 'n_tokens_mistral': 1397, 'n_tokens_neox': 1343, 'n_words': 302}