<commit_before>import { Observable } from 'rxjs';
import { Component, NgZone } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Store } from '@ngrx/store';

import { IAppState } from './../../state';
import { IDeviceInfo } from './../../plugin';
import { ScanActions } from './../../actions';

import { ServicesPage } from './../services/services';

@Component({
  templateUrl: 'build/pages/home/home.html'
})
export class HomePage {

  startScanEnabled$: Observable<boolean>;
  stopScanEnabled$: Observable<boolean>;

  devices$: Observable<Array<IDeviceInfo>>;

  constructor(
    private store: Store<IAppState>,
    private scanActions: ScanActions,
    private navCtrl: NavController,
    private ngZone: NgZone) {

    this.devices$ = store.select(s => s.scan.devices);

    const permission$ = store.select(s => s.scan.permission);
    const scanning$ = store.select(s => s.scan.scanning);

    this.startScanEnabled$ = Observable.combineLatest(
      permission$, scanning$, (permission: boolean, scanning: boolean) => {
        return permission && !scanning;
      });

    this.stopScanEnabled$ = Observable.combineLatest(
      permission$, scanning$, (permission: boolean, scanning: boolean) => {
        return permission && scanning;
      });

    this.store.dispatch(this.scanActions.requestPermission());
  }

  startScan() {
    this.store.dispatch(this.scanActions.startScan());
  }

  stopScan() {
    this.store.dispatch(this.scanActions.stopScan());
  }

  connectToDevice(device: IDeviceInfo) {
    this.navCtrl.push(ServicesPage, {
      selectedDevice: device
    });
  }
}
<commit_msg>fix - in HomePage, fire requestPermission action when platform is android otherwise dispatch the permissionGranted action<commit_after>import { Observable } from 'rxjs';
import { Component, NgZone } from '@angular/core';
import { NavController, Platform } from 'ionic-angular';
import { Store } from '@ngrx/store';

import { IAppState } from './../../state';
import { IDeviceInfo } from './../../plugin';
import { ScanActions } from './../../actions';

import { ServicesPage } from './../services/services';

@Component({
  templateUrl: 'build/pages/home/home.html'
})
export class HomePage {

  startScanEnabled$: Observable<boolean>;
  stopScanEnabled$: Observable<boolean>;

  devices$: Observable<Array<IDeviceInfo>>;

  constructor(
    private platform: Platform,
    private store: Store<IAppState>,
    private scanActions: ScanActions,
    private navCtrl: NavController,
    private ngZone: NgZone) {

    this.devices$ = store.select(s => s.scan.devices);

    const permission$ = store.select(s => s.scan.permission);
    const scanning$ = store.select(s => s.scan.scanning);

    this.startScanEnabled$ = Observable.combineLatest(
      permission$, scanning$, (permission: boolean, scanning: boolean) => {
        return permission && !scanning;
      });

    this.stopScanEnabled$ = Observable.combineLatest(
      permission$, scanning$, (permission: boolean, scanning: boolean) => {
        return permission && scanning;
      });

    if (platform.is('android')) {
      this.store.dispatch(this.scanActions.requestPermission());
    } else {
      this.store.dispatch(this.scanActions.permissionGranted());
    }
  }

  startScan() {
    this.store.dispatch(this.scanActions.startScan());
  }

  stopScan() {
    this.store.dispatch(this.scanActions.stopScan());
  }

  connectToDevice(device: IDeviceInfo) {
    this.navCtrl.push(ServicesPage, {
      selectedDevice: device
    });
  }
}

{'fraction_non_alphanumeric': 0.14780405405405406, 'fraction_numerical': 0.0, 'mean_word_length': 3.675, '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': '7020454', 'n_tokens_mistral': 1042, 'n_tokens_neox': 1001, 'n_words': 224}