<commit_before>import * as React from "react";
import * as Rx from "rx-lite";
import { LandingPage } from "../pages/landing-page-component";
import { SummaryPage } from "../pages/summary-page-component";
import { component } from "../cycle-rx-utils/components";
import * as state from "../frontend-app-state-machine/frontend-app-state";
import {FrontendAppState} from "../frontend-app-state-machine/frontend-app-state";
import {FrontendAppStateMachine} from "../frontend-app-state-machine/frontend-app-state-machine";
import {StudyPage} from "../pages/study-page-component";

interface Props {
  stateMachine?: FrontendAppStateMachine
  appState: FrontendAppState
}

export var FrontendMainComponent = component<Props>("FrontendMain",
  (interactions, prop$) => {
    var appState$ = prop$.map(({appState}) => appState);
    var stateMachine$ = prop$.map(({stateMachine}) => stateMachine);

    return appState$.combineLatest<FrontendAppStateMachine, [FrontendAppState, FrontendAppStateMachine]>(
      stateMachine$, (appState, stateMachine) => [appState, stateMachine])
      .map(([appState, stateMachine]) => {
        switch (appState.currentPage) {
          case state.CurrentPage.LOGGED_OUT:
            return <LandingPage/>;
          case state.CurrentPage.SUMMARY:
            return <SummaryPage
              onNewFilter={!!stateMachine ? stateMachine.addFilter.listener : null}
              onFilterChange={!!stateMachine ? stateMachine.changeFilter.listener : null}
              onQueueMaxChange={!!stateMachine ? stateMachine.changeQueueMax.listener : null}
              onBeginStudying={!!stateMachine ? stateMachine.beginStudy.listener : null}
              onRefresh={!!stateMachine ? stateMachine.visitSummary.listener : null}
              appState={appState}/>;
          case state.CurrentPage.STUDYING:
            return <StudyPage
              appState={appState}
              onAnswer={!!stateMachine ? stateMachine.answerCard.listener : null}
              onFinishStudy={!!stateMachine ? stateMachine.visitSummary.listener : null}
              onRequestImageIds={!!stateMachine ? stateMachine.requestImages.listener : null}
              onShowHide={!!stateMachine ? stateMachine.showHideAnswer.listener : null}/>;
        }
      })
  });<commit_msg>Refresh calls sync directly.<commit_after>import * as React from "react";
import * as Rx from "rx-lite";
import { LandingPage } from "../pages/landing-page-component";
import { SummaryPage } from "../pages/summary-page-component";
import { component } from "../cycle-rx-utils/components";
import * as state from "../frontend-app-state-machine/frontend-app-state";
import {FrontendAppState} from "../frontend-app-state-machine/frontend-app-state";
import {FrontendAppStateMachine} from "../frontend-app-state-machine/frontend-app-state-machine";
import {StudyPage} from "../pages/study-page-component";

interface Props {
  stateMachine?: FrontendAppStateMachine
  appState: FrontendAppState
}

export var FrontendMainComponent = component<Props>("FrontendMain",
  (interactions, prop$) => {
    var appState$ = prop$.map(({appState}) => appState);
    var stateMachine$ = prop$.map(({stateMachine}) => stateMachine);

    return appState$.combineLatest<FrontendAppStateMachine, [FrontendAppState, FrontendAppStateMachine]>(
      stateMachine$, (appState, stateMachine) => [appState, stateMachine])
      .map(([appState, stateMachine]) => {
        switch (appState.currentPage) {
          case state.CurrentPage.LOGGED_OUT:
            return <LandingPage/>;
          case state.CurrentPage.SUMMARY:
            return <SummaryPage
              onNewFilter={!!stateMachine ? stateMachine.addFilter.listener : null}
              onFilterChange={!!stateMachine ? stateMachine.changeFilter.listener : null}
              onQueueMaxChange={!!stateMachine ? stateMachine.changeQueueMax.listener : null}
              onBeginStudying={!!stateMachine ? stateMachine.beginStudy.listener : null}
              onRefresh={!!stateMachine ? stateMachine.requestSync.listener : null}
              appState={appState}/>;
          case state.CurrentPage.STUDYING:
            return <StudyPage
              appState={appState}
              onAnswer={!!stateMachine ? stateMachine.answerCard.listener : null}
              onFinishStudy={!!stateMachine ? stateMachine.visitSummary.listener : null}
              onRequestImageIds={!!stateMachine ? stateMachine.requestImages.listener : null}
              onShowHide={!!stateMachine ? stateMachine.showHideAnswer.listener : null}/>;
        }
      })
  });
{'fraction_non_alphanumeric': 0.12707061900610286, 'fraction_numerical': 0.0, 'mean_word_length': 3.4167468719923004, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 23, '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': '5888101', 'n_tokens_mistral': 1246, 'n_tokens_neox': 1219, 'n_words': 229}