<commit_before>import { Injectable } from '@angular/core';

import { StepService, StepInfo } from '../../controller/step/step.service';
import { FileService } from '../../file/file.service';
import { SpeedService } from '../../fretboard/speed/speed.service';
import { ModelService } from '../../model/model.service';
import { TimeService } from '../../time/time.service';
import { VolumeService } from '../../time/volume/volume.service';

@Injectable()
export class StorageService {

    constructor(
        private stepService: StepService,
        private fileService: FileService,
        private speedService: SpeedService,
        private modelService: ModelService,
        private timeService: TimeService,
        private volumeService: VolumeService,
    ) {
        this.load();
        this.stepService.stepInfos.subscribe(si => this.save('stepInfo', si));
        this.fileService.chartFileNames.subscribe(cfn => this.save('chartFileName', cfn));
        this.speedService.speeds.subscribe(s => this.save('speed', s));
        this.modelService.models.subscribe(m => this.save('model', m));
        this.timeService.times.subscribe((t) => {
            if (!this.timeService.playing) {
                this.save('time', t);
            }
        });
        this.volumeService.volumes.subscribe(v => this.save('volume', v));
    }

    private save(name: string, value: any): void {
        localStorage.setItem(name, JSON.stringify(value));
    }

    private load(): void {
        this.loadStepInfo();
        this.loadChartFileName();
    }

    private loadStepInfo(): void {
        const stepInfoString = localStorage.getItem('stepInfo');
        if (stepInfoString) {
            const stepInfo = JSON.parse(stepInfoString) as StepInfo;
            this.stepService.newStep(
                stepInfo.stepControl,
                stepInfo.customStepTop,
                stepInfo.customStepBottom,
            );
        }
    }

    private loadChartFileName(): void {
        const chartFileNameString = localStorage.getItem('chartFileName');
        if (chartFileNameString) {
            const chartFileName = JSON.parse(chartFileNameString) as string;
            this.fileService.loadChartFileName(chartFileName);
        }
    }
}<commit_msg>feat: Load speed<commit_after>import { Injectable } from '@angular/core';

import { StepService, StepInfo } from '../../controller/step/step.service';
import { FileService } from '../../file/file.service';
import { SpeedService } from '../../fretboard/speed/speed.service';
import { ModelService } from '../../model/model.service';
import { TimeService } from '../../time/time.service';
import { VolumeService } from '../../time/volume/volume.service';

@Injectable()
export class StorageService {

    constructor(
        private stepService: StepService,
        private fileService: FileService,
        private speedService: SpeedService,
        private modelService: ModelService,
        private timeService: TimeService,
        private volumeService: VolumeService,
    ) {
        this.load();
        this.stepService.stepInfos.subscribe(si => this.save('stepInfo', si));
        this.fileService.chartFileNames.subscribe(cfn => this.save('chartFileName', cfn));
        this.speedService.speeds.subscribe(s => this.save('speed', s));
        this.modelService.models.subscribe(m => this.save('model', m));
        this.timeService.times.subscribe((t) => {
            if (!this.timeService.playing) {
                this.save('time', t);
            }
        });
        this.volumeService.volumes.subscribe(v => this.save('volume', v));
    }

    private save(name: string, value: any): void {
        localStorage.setItem(name, JSON.stringify(value));
    }

    private load(): void {
        this.loadStepInfo();
        this.loadChartFileName();
        this.loadSpeed();
    }

    private loadStepInfo(): void {
        const stepInfoString = localStorage.getItem('stepInfo');
        if (stepInfoString) {
            const stepInfo = JSON.parse(stepInfoString) as StepInfo;
            this.stepService.newStep(
                stepInfo.stepControl,
                stepInfo.customStepTop,
                stepInfo.customStepBottom,
            );
        }
    }

    private loadChartFileName(): void {
        const chartFileNameString = localStorage.getItem('chartFileName');
        if (chartFileNameString) {
            const chartFileName = JSON.parse(chartFileNameString) as string;
            this.fileService.loadChartFileName(chartFileName);
        }
    }

    private loadSpeed(): void {
        const speedString = localStorage.getItem('speed');
        if (speedString) {
            const speed = JSON.parse(speedString) as number;
            this.speedService.speed = speed;
        }
    }
}
{'fraction_non_alphanumeric': 0.13108614232209737, 'fraction_numerical': 0.0, 'mean_word_length': 2.4985443959243088, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '661543', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1259, 'n_words': 252}