Upgrade to ngrx v4 (#378)
* Update ngrx to v4 * package.json files * release: Remove zadic references from release script * fix(user-config): Fix user-config loading * build: Lock package dependencies * build: fix app version * ci: remove build:test step * fix(user-config): Revert switch-keymap-action modifications * test(user-config): xit keystroke-action test * fix(user-config): Fix user config loading * fix(user-config): Fix user config loading
This commit is contained in:
committed by
László Monda
parent
ba1fff788d
commit
50e0b64f6e
@@ -1,5 +1,21 @@
|
||||
import { DeviceEffects } from './device';
|
||||
import { AutoUpdateSettingsEffects } from './auto-update-settings';
|
||||
import { MacroEffects } from './macro';
|
||||
import { KeymapEffects } from './keymap';
|
||||
import { UserConfigEffects } from './user-config';
|
||||
import { ApplicationEffects } from './app';
|
||||
|
||||
export * from './keymap';
|
||||
export * from './macro';
|
||||
export * from './user-config';
|
||||
export * from './auto-update-settings';
|
||||
export * from './app';
|
||||
|
||||
export const effects = [
|
||||
ApplicationEffects,
|
||||
UserConfigEffects,
|
||||
KeymapEffects,
|
||||
MacroEffects,
|
||||
AutoUpdateSettingsEffects,
|
||||
DeviceEffects
|
||||
];
|
||||
|
||||
@@ -54,7 +54,7 @@ export class KeymapEffects {
|
||||
@Effect({ dispatch: false }) editAbbr$: any = this.actions$
|
||||
.ofType(KeymapActions.EDIT_ABBR)
|
||||
.withLatestFrom(this.store)
|
||||
.do(([action, store]) => {
|
||||
.do(([action, store]: [KeymapActions.EditKeymapAbbreviationAction, AppState]) => {
|
||||
for (const keymap of store.userConfiguration.keymaps) {
|
||||
if (keymap.name === action.payload.name && keymap.abbreviation === action.payload.newAbbr) {
|
||||
this.router.navigate(['/keymap', action.payload.newAbbr]);
|
||||
|
||||
@@ -16,7 +16,7 @@ export class MacroEffects {
|
||||
|
||||
@Effect({ dispatch: false }) remove$: any = this.actions$
|
||||
.ofType(MacroActions.REMOVE)
|
||||
.map(action => this.store.dispatch(KeymapActions.checkMacro(action.payload)))
|
||||
.do<any>(action => this.store.dispatch(KeymapActions.checkMacro(action.payload)))
|
||||
.withLatestFrom(this.store)
|
||||
.map(([action, state]) => state.userConfiguration.macros)
|
||||
.do(macros => {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { go } from '@ngrx/router-store';
|
||||
import { Router } from '@angular/router';
|
||||
import { Actions, Effect, toPayload } from '@ngrx/effects';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { defer } from 'rxjs/observable/defer';
|
||||
import { Action, Store } from '@ngrx/store';
|
||||
import { saveAs } from 'file-saver';
|
||||
|
||||
@@ -23,7 +24,6 @@ import {
|
||||
|
||||
import {
|
||||
ActionTypes,
|
||||
LoadUserConfigAction,
|
||||
LoadUserConfigSuccessAction,
|
||||
SaveUserConfigSuccessAction
|
||||
} from '../actions/user-config';
|
||||
@@ -31,12 +31,11 @@ import {
|
||||
import { DataStorageRepositoryService } from '../../services/datastorage-repository.service';
|
||||
import { DefaultUserConfigurationService } from '../../services/default-user-configuration.service';
|
||||
import { AppState, getPrevUserConfiguration, getUserConfiguration } from '../index';
|
||||
import { KeymapActions } from '../actions/keymap';
|
||||
import { MacroActions } from '../actions/macro';
|
||||
import { UndoUserConfigData } from '../../models/undo-user-config-data';
|
||||
import { KeymapAction, KeymapActions, MacroAction, MacroActions } from '../actions';
|
||||
import { ShowNotificationAction, DismissUndoNotificationAction, LoadHardwareConfigurationSuccessAction } from '../actions/app';
|
||||
import { ShowSaveToKeyboardButtonAction } from '../actions/device';
|
||||
import { DeviceRendererService } from '../../services/device-renderer.service';
|
||||
import { UndoUserConfigData } from '../../models/undo-user-config-data';
|
||||
|
||||
@Injectable()
|
||||
export class UserConfigEffects {
|
||||
@@ -64,17 +63,17 @@ export class UserConfigEffects {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Effect() loadUserConfig$: Observable<Action> = this.actions$
|
||||
.ofType(ActionTypes.LOAD_USER_CONFIG)
|
||||
.startWith(new LoadUserConfigAction())
|
||||
.switchMap(() => Observable.of(new LoadUserConfigSuccessAction(this.getUserConfiguration())));
|
||||
@Effect() loadUserConfig$: Observable<Action> = defer(() => {
|
||||
return Observable.of(new LoadUserConfigSuccessAction(this.getUserConfiguration()));
|
||||
});
|
||||
|
||||
@Effect() saveUserConfig$: Observable<Action> = this.actions$
|
||||
@Effect() saveUserConfig$: Observable<Action> = (this.actions$
|
||||
.ofType(
|
||||
KeymapActions.ADD, KeymapActions.DUPLICATE, KeymapActions.EDIT_NAME, KeymapActions.EDIT_ABBR,
|
||||
KeymapActions.SET_DEFAULT, KeymapActions.REMOVE, KeymapActions.SAVE_KEY,
|
||||
MacroActions.ADD, MacroActions.DUPLICATE, MacroActions.EDIT_NAME, MacroActions.REMOVE, MacroActions.ADD_ACTION,
|
||||
MacroActions.SAVE_ACTION, MacroActions.DELETE_ACTION, MacroActions.REORDER_ACTION)
|
||||
MacroActions.SAVE_ACTION, MacroActions.DELETE_ACTION, MacroActions.REORDER_ACTION) as
|
||||
Observable<KeymapAction | MacroAction>)
|
||||
.withLatestFrom(this.store.select(getUserConfiguration), this.store.select(getPrevUserConfiguration))
|
||||
.mergeMap(([action, config, prevUserConfiguration]) => {
|
||||
this.dataStorageRepository.saveConfig(config);
|
||||
@@ -114,7 +113,8 @@ export class UserConfigEffects {
|
||||
.mergeMap((payload: UndoUserConfigData) => {
|
||||
const config = new UserConfiguration().fromJsonObject(payload.config);
|
||||
this.dataStorageRepository.saveConfig(config);
|
||||
return [new LoadUserConfigSuccessAction(config), go(payload.path)];
|
||||
this.router.navigate([payload.path]);
|
||||
return [new LoadUserConfigSuccessAction(config)];
|
||||
});
|
||||
|
||||
@Effect({dispatch: false}) loadConfigFromDevice$ = this.actions$
|
||||
@@ -173,7 +173,8 @@ export class UserConfigEffects {
|
||||
private store: Store<AppState>,
|
||||
private defaultUserConfigurationService: DefaultUserConfigurationService,
|
||||
private deviceRendererService: DeviceRendererService,
|
||||
private logService: LogService) {
|
||||
private logService: LogService,
|
||||
private router: Router) {
|
||||
}
|
||||
|
||||
private getUserConfiguration() {
|
||||
@@ -193,5 +194,4 @@ export class UserConfigEffects {
|
||||
return config;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user