feat(device): Reset user configuration on device (#435)
This commit is contained in:
committed by
László Monda
parent
23af522a48
commit
ba1fff788d
@@ -11,6 +11,7 @@ import 'rxjs/add/operator/do';
|
||||
import 'rxjs/add/operator/map';
|
||||
import 'rxjs/add/operator/mergeMap';
|
||||
import 'rxjs/add/operator/withLatestFrom';
|
||||
import 'rxjs/add/operator/switchMap';
|
||||
|
||||
import { NotificationType, IpcResponse, UhkBuffer, UserConfiguration } from 'uhk-common';
|
||||
import {
|
||||
@@ -18,13 +19,19 @@ import {
|
||||
ConnectionStateChangedAction,
|
||||
HideSaveToKeyboardButton,
|
||||
PermissionStateChangedAction,
|
||||
SaveConfigurationAction,
|
||||
SaveToKeyboardSuccessAction,
|
||||
SaveToKeyboardSuccessFailed
|
||||
} from '../actions/device';
|
||||
import { DeviceRendererService } from '../../services/device-renderer.service';
|
||||
import { ShowNotificationAction } from '../actions/app';
|
||||
import { AppState } from '../index';
|
||||
import { LoadConfigFromDeviceAction } from '../actions/user-config';
|
||||
import {
|
||||
LoadConfigFromDeviceAction,
|
||||
LoadResetUserConfigurationAction,
|
||||
ActionTypes as UserConfigActions
|
||||
} from '../actions/user-config';
|
||||
import { DefaultUserConfigurationService } from '../../services/default-user-configuration.service';
|
||||
|
||||
@Injectable()
|
||||
export class DeviceEffects {
|
||||
@@ -124,10 +131,22 @@ export class DeviceEffects {
|
||||
.switchMap(() => Observable.of(new HideSaveToKeyboardButton()))
|
||||
);
|
||||
|
||||
@Effect() resetUserConfiguration$: Observable<Action> = this.actions$
|
||||
.ofType(ActionTypes.RESET_USER_CONFIGURATION)
|
||||
.switchMap(() => {
|
||||
const config = this.defaultUserConfigurationService.getDefault();
|
||||
return Observable.of(new LoadResetUserConfigurationAction(config));
|
||||
});
|
||||
|
||||
@Effect() saveResetUserConfigurationToDevice$ = this.actions$
|
||||
.ofType(UserConfigActions.LOAD_RESET_USER_CONFIGURATION)
|
||||
.switchMap(() => Observable.of(new SaveConfigurationAction()));
|
||||
|
||||
constructor(private actions$: Actions,
|
||||
private router: Router,
|
||||
private deviceRendererService: DeviceRendererService,
|
||||
private store: Store<AppState>) {
|
||||
private store: Store<AppState>,
|
||||
private defaultUserConfigurationService: DefaultUserConfigurationService) {
|
||||
}
|
||||
|
||||
private sendUserConfigToKeyboard(userConfiguration: UserConfiguration): void {
|
||||
|
||||
@@ -144,7 +144,7 @@ export class UserConfigEffects {
|
||||
this.logService.error('Eeprom parse error:', err);
|
||||
return [new ShowNotificationAction({
|
||||
type: NotificationType.Error,
|
||||
message: err.message
|
||||
message: err
|
||||
})];
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user