<commit_before>import { isPlatformServer } from '@angular/common';
import {
  Component,
  ElementRef,
  Inject,
  Input,
  PLATFORM_ID,
  ViewChild,
} from '@angular/core';
import { BehaviorSubject, interval, Observable } from 'rxjs';
import {
  distinctUntilChanged,
  last,
  map,
  startWith,
  switchMap,
} from 'rxjs/operators';
import { FriendlyDateDiffPipe } from '../../../../../common/pipes/friendlydatediff';
import { ActivityEntity } from '../../activity.service';

/**
 * Shows relative time ago in a span element e.g. 30s ago
 * Time will only update when the host is on screen.
 */
@Component({
  selector: 'm-relativeTimeSpan',
  template: `
    <span
      class="m-relativeTime__span"
      [title]="entity.time_created * 1000 | date: 'medium'"
      #relativeTimeSpan
    >
      {{ pauseableRelativeTimeAgo$ | async }}
    </span>
  `,
  styleUrls: ['./relative-time-span.component.ng.scss'],
  providers: [FriendlyDateDiffPipe],
})
export class ActivityRelativeTimeSpanComponent {
  // activity entity to get time from.
  @Input('entity') entity: ActivityEntity;

  // Reference to hosts span element.
  @ViewChild('relativeTimeSpan') relativeTimeSpan: ElementRef;

  /**
   * Relative time ago - e.g. 42 seconds ago.
   * Emits every second.<commit_msg>(fix): SSR failing to load on newsfeed pages due to interval polling<commit_after>import { isPlatformServer } from '@angular/common';
import {
  Component,
  ElementRef,
  Inject,
  Input,
  PLATFORM_ID,
  ViewChild,
} from '@angular/core';
import { BehaviorSubject, interval, Observable } from 'rxjs';
import {
  distinctUntilChanged,
  last,
  map,
  startWith,
  switchMap,
} from 'rxjs/operators';
import { FriendlyDateDiffPipe } from '../../../../../common/pipes/friendlydatediff';
import { ActivityEntity } from '../../activity.service';

/**
 * Shows relative time ago in a span element e.g. 30s ago
 * Time will only update when the host is on screen.
 */
@Component({
  selector: 'm-relativeTimeSpan',
  template: `
    <span
      class="m-relativeTime__span"
      [title]="entity.time_created * 1000 | date: 'medium'"
      #relativeTimeSpan
      *mIfBrowser
    >
      {{ pauseableRelativeTimeAgo$ | async }}
    </span>
  `,
  styleUrls: ['./relative-time-span.component.ng.scss'],
  providers: [FriendlyDateDiffPipe],
})
export class ActivityRelativeTimeSpanComponent {
  // activity entity to get time from.
  @Input('entity') entity: ActivityEntity;

  // Reference to hosts span element.
  @ViewChild('relativeTimeSpan') relativeTimeSpan: ElementRef;

  /**
   * Relative time ago - e.g. 42 seconds ago.
   * Emits every second.
{'fraction_non_alphanumeric': 0.1341974837971788, 'fraction_numerical': 0.006099885627144491, 'mean_word_length': 3.5319516407599307, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6652801', 'n_tokens_mistral': 821, 'n_tokens_neox': 802, 'n_words': 219}