Files
agent/shared/src/store/effects/user-config.ts
Róbert Kiss 367bc42457 refactor(store): Refactor reducer initialisation (#298)
* refactor(store): Refactor reducer initialization

Refactored the ngrx/store reducer initialization, because hard to extend the original solution.
Bad practise the object initialization inside the components / services. The new solution use angular DI everywhere.
Separated the web and electron configuration store.

* Media key support (#294)

* Introduce type for KeystrokeAction

* Increment dataModelVersion

New property 'type' for KeystrokeAction

* Mapping for media keys

* Media key selecting support for KeypressTab

* refactor: Use more meaningful name (selectedScancodeOption)

* Store the keystroke type in key action type instead of a new field

* Fix NoneAction validation
Fixes #301

* Update electron version

It fixes electron build. The types are part of the electron package itself.

* Fix keystroke selection when additional field is given but no scancode (#306)

* Additional media keys with icons (#307)

* Add missing scancodes for media keystrokes

* Use icons for media keys

* Fix media scancodes.

* Create README.md

* build: upgrade electron and typescript version

Electron contains the typings files.

* refactor(store): Refactor reducer initialization

Refactored the ngrx/store reducer initialization, because hard to extend the original solution.
Bad practise the object initialization inside the components / services. The new solution use angular DI everywhere.
Separated the web and electron configuration store.

* build: upgrade electron and typescript version

Electron contains the typings files.

* fix(store): Remove the I prefix from IDataStorageRepositoryService

* fix(store): fix observer operator import

* fix(store): Add missing rxjs imports to user-config effect

* fix(store): Add missing rxjs imports to keymap effect
2017-06-13 14:41:40 +02:00

33 lines
1.5 KiB
TypeScript

import { Injectable, Inject } from '@angular/core';
import { Effect, Actions } from '@ngrx/effects';
import { Observable } from 'rxjs/Observable';
import { Action } from '@ngrx/store';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/startWith';
import 'rxjs/add/observable/of';
import { ActionTypes, LoadUserConfigAction, LoadUserConfigSuccessAction } from '../actions/user-config';
import { UserConfiguration } from '../../config-serializer/config-items/UserConfiguration';
import { DataStorageRepositoryService, DATA_STORAGE_REPOSITORY } from '../../services/datastorage-repository.service';
import { DefaultUserConfigurationService } from '../../services/default-user-configuration.service';
@Injectable()
export class UserConfigEffects {
@Effect() loadUserConfig$: Observable<Action> = this.actions$
.ofType(ActionTypes.LOAD_USER_CONFIG)
.startWith(new LoadUserConfigAction())
.switchMap(() => {
let config: UserConfiguration = this.dataStorageRepository.getConfig();
if (!config) {
config = this.defaultUserConfigurationService.getDefault();
}
return Observable.of(new LoadUserConfigSuccessAction(config));
});
constructor(private actions$: Actions,
@Inject(DATA_STORAGE_REPOSITORY)private dataStorageRepository: DataStorageRepositoryService,
private defaultUserConfigurationService: DefaultUserConfigurationService) { }
}