<commit_before>import { Component, OnInit } from '@angular/core';
import { AppSettings } from './../../shared/appsettings';
import { Observable, Subscription } from 'rxjs';
import { Store } from '@ngrx/store';
import { AppState } from './../../store/appstate';
import { SettingsService } from './../../services/settings.service';

@Component({
    moduleId: module.id,
    selector: 'settingspage',
    templateUrl: 'settingspage.component.html',
    styleUrls: ['settingspage.component.css']
})
export class SettingspageComponent implements OnInit {

    public settings: AppSettings;
    public selectedIndex: number;
    public items = [];
    public pickerVisible: boolean = false;
    public speedUnits: string;

    private itemValues = [];
    private settings$Sub: Subscription;
    private useSelectedIndex: boolean;

    constructor(private store: Store<AppState>, private settingsService: SettingsService) { }

    ngOnInit() {

        this.items = ['m/s', 'km/h', 'knots'];
        this.itemValues = ['ms', 'kmh', 'kt'];

        let settings$ = <Observable<AppSettings>>this.store.select('settings');
        this.settings$Sub = settings$.subscribe(storeSettings => {
            this.settings = Object.assign({}, storeSettings);
            console.log('subscribe: ', this.itemValues.indexOf(this.settings.speedUnits));
            this.setValues(this.itemValues.indexOf(this.settings.speedUnits));
        });
    }

    selectedIndexChanged(picker) {
        console.log('selectedIndexChanged: ', picker.selectedIndex, this.pickerVisible, this.useSelectedIndex);
        if (this.useSelectedIndex) {
            this.setValues(picker.selectedIndex);
        }
        this.useSelectedIndex = true;
    }

    private setValues(index: number) {
        console.log('setValues', index);
        this.selectedIndex = index;
        this.settings.speedUnits = this.itemValues[index];
        this.speedUnits = this.items[index];
    }

    toggleList() {
        this.pickerVisible = !this.pickerVisible;
        this.useSelectedIndex = false;
    }
<commit_msg>#2 removed debug code<commit_after>import { Component, OnInit } from '@angular/core';
import { AppSettings } from './../../shared/appsettings';
import { Observable, Subscription } from 'rxjs';
import { Store } from '@ngrx/store';
import { AppState } from './../../store/appstate';
import { SettingsService } from './../../services/settings.service';

@Component({
    moduleId: module.id,
    selector: 'settingspage',
    templateUrl: 'settingspage.component.html',
    styleUrls: ['settingspage.component.css']
})
export class SettingspageComponent implements OnInit {

    public settings: AppSettings;
    public selectedIndex: number;
    public items = [];
    public pickerVisible: boolean = false;
    public speedUnits: string;

    private itemValues = [];
    private settings$Sub: Subscription;
    private useSelectedIndex: boolean;

    constructor(private store: Store<AppState>, private settingsService: SettingsService) { }

    ngOnInit() {

        this.items = ['m/s', 'km/h', 'knots'];
        this.itemValues = ['ms', 'kmh', 'kt'];

        let settings$ = <Observable<AppSettings>>this.store.select('settings');
        this.settings$Sub = settings$.subscribe(storeSettings => {
            this.settings = Object.assign({}, storeSettings);
            this.setValues(this.itemValues.indexOf(this.settings.speedUnits));
        });
    }

    selectedIndexChanged(picker) {
        if (this.useSelectedIndex) {
            this.setValues(picker.selectedIndex);
        }
        this.useSelectedIndex = true;
    }

    private setValues(index: number) {
        this.selectedIndex = index;
        this.settings.speedUnits = this.itemValues[index];
        this.speedUnits = this.items[index];
    }

    toggleList() {
        this.pickerVisible = !this.pickerVisible;
        this.useSelectedIndex = false;
    }

{'fraction_non_alphanumeric': 0.13668880940214614, 'fraction_numerical': 0.0002554931016862545, 'mean_word_length': 3.1210526315789475, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '3860272', 'n_tokens_mistral': 1073, 'n_tokens_neox': 1065, 'n_words': 225}