Seperate electron and web target building
This commit is contained in:
committed by
József Farkas
parent
517aed1b1c
commit
983eb72892
2
shared/src/store/effects/index.ts
Normal file
2
shared/src/store/effects/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './keymap';
|
||||
export * from './macro';
|
||||
60
shared/src/store/effects/keymap.ts
Normal file
60
shared/src/store/effects/keymap.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { Actions, Effect } from '@ngrx/effects';
|
||||
import { Store } from '@ngrx/store';
|
||||
|
||||
import 'rxjs/add/operator/do';
|
||||
import 'rxjs/add/operator/map';
|
||||
import 'rxjs/add/operator/withLatestFrom';
|
||||
|
||||
import { KeymapActions } from '../actions';
|
||||
import { AppState } from '../index';
|
||||
|
||||
import { Keymap } from '../../config-serializer/config-items/Keymap';
|
||||
|
||||
@Injectable()
|
||||
export class KeymapEffects {
|
||||
|
||||
@Effect({ dispatch: false })add$: any = this.actions$
|
||||
.ofType(KeymapActions.ADD)
|
||||
.withLatestFrom(this.store)
|
||||
.do((latest) => {
|
||||
const state: AppState = latest[1];
|
||||
const entities: Keymap[] = state.keymaps.entities;
|
||||
this.router.navigate(['/keymap', entities[entities.length - 1].abbreviation]);
|
||||
});
|
||||
|
||||
@Effect({ dispatch: false }) duplicate$: any = this.actions$
|
||||
.ofType(KeymapActions.DUPLICATE)
|
||||
.withLatestFrom(this.store)
|
||||
.do((latest) => {
|
||||
const state: AppState = latest[1];
|
||||
const entities: Keymap[] = state.keymaps.entities;
|
||||
this.router.navigate(['/keymap', entities[entities.length - 1].abbreviation]);
|
||||
});
|
||||
|
||||
@Effect({ dispatch: false })remove$: any = this.actions$
|
||||
.ofType(KeymapActions.REMOVE)
|
||||
.withLatestFrom(this.store)
|
||||
.do((latest) => {
|
||||
const state: AppState = latest[1];
|
||||
|
||||
if (state.keymaps.entities.length === 0) {
|
||||
this.router.navigate(['/keymap/add']);
|
||||
} else {
|
||||
const favourite: Keymap = state.keymaps.entities.find(keymap => keymap.isDefault);
|
||||
this.router.navigate(['/keymap', favourite.abbreviation]);
|
||||
}
|
||||
});
|
||||
|
||||
@Effect({ dispatch: false }) editAbbr$: any = this.actions$
|
||||
.ofType(KeymapActions.EDIT_ABBR)
|
||||
.withLatestFrom(this.store)
|
||||
.do((latest) => {
|
||||
const state: AppState = latest[1];
|
||||
this.router.navigate(['/keymap', state.keymaps.newAbbr]);
|
||||
});
|
||||
|
||||
constructor(private actions$: Actions, private router: Router, private store: Store<AppState>) {}
|
||||
}
|
||||
45
shared/src/store/effects/macro.ts
Normal file
45
shared/src/store/effects/macro.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { Actions, Effect } from '@ngrx/effects';
|
||||
import { Store } from '@ngrx/store';
|
||||
|
||||
import 'rxjs/add/operator/do';
|
||||
import 'rxjs/add/operator/map';
|
||||
import 'rxjs/add/operator/withLatestFrom';
|
||||
|
||||
import { Macro } from '../../config-serializer/config-items/Macro';
|
||||
|
||||
import { KeymapActions, MacroActions } from '../actions';
|
||||
import { AppState } from '../index';
|
||||
|
||||
@Injectable()
|
||||
export class MacroEffects {
|
||||
|
||||
@Effect({dispatch: false}) remove$: any = this.actions$
|
||||
.ofType(MacroActions.REMOVE)
|
||||
.map(action => this.store.dispatch(KeymapActions.checkMacro(action.payload)))
|
||||
.withLatestFrom(this.store)
|
||||
.do((latest) => {
|
||||
const state: AppState = latest[1];
|
||||
const macro: Macro[] = state.macros.entities;
|
||||
|
||||
if (state.macros.entities.length === 0) {
|
||||
this.router.navigate(['/macro']);
|
||||
} else {
|
||||
this.router.navigate(['/macro', macro[0].id]);
|
||||
}
|
||||
});
|
||||
|
||||
@Effect({dispatch: false}) add$: any = this.actions$
|
||||
.ofType(MacroActions.ADD)
|
||||
.withLatestFrom(this.store)
|
||||
.do((latest) => {
|
||||
const state: AppState = latest[1];
|
||||
const macro: Macro = state.macros.entities[state.macros.entities.length - 1];
|
||||
|
||||
this.router.navigate(['/macro', macro.id, 'new']);
|
||||
});
|
||||
|
||||
constructor(private actions$: Actions, private router: Router, private store: Store<AppState>) {}
|
||||
}
|
||||
Reference in New Issue
Block a user