exit from app
This commit is contained in:
@@ -21,6 +21,11 @@ export class AppRendererService {
|
||||
this.ipcRenderer.send(IpcEvents.app.getAppStartInfo);
|
||||
}
|
||||
|
||||
exit() {
|
||||
this.logService.info('[AppRendererService] exit');
|
||||
this.ipcRenderer.send(IpcEvents.app.exit);
|
||||
}
|
||||
|
||||
private registerEvents() {
|
||||
this.ipcRenderer.on(IpcEvents.app.getAppStartInfoReply, (event: string, arg: AppStartInfo) => {
|
||||
this.dispachStoreAction(new ProcessAppStartInfoAction(arg));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Action } from '@ngrx/store';
|
||||
import { Action, Store } from '@ngrx/store';
|
||||
import { Actions, Effect } from '@ngrx/effects';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { NotifierService } from 'angular-notifier';
|
||||
@@ -13,16 +13,23 @@ import 'rxjs/add/operator/catch';
|
||||
import { AppStartInfo, LogService, Notification, NotificationType } from 'uhk-common';
|
||||
import {
|
||||
ActionTypes,
|
||||
ApplyCommandLineArgsAction,
|
||||
AppStartedAction,
|
||||
DismissUndoNotificationAction,
|
||||
ProcessAppStartInfoAction,
|
||||
ShowNotificationAction,
|
||||
ApplyCommandLineArgsAction,
|
||||
UndoLastAction, UpdateAgentVersionInformationAction
|
||||
UndoLastAction,
|
||||
UpdateAgentVersionInformationAction
|
||||
} from '../actions/app';
|
||||
import { AppRendererService } from '../../services/app-renderer.service';
|
||||
import { AppUpdateRendererService } from '../../services/app-update-renderer.service';
|
||||
import { ConnectionStateChangedAction, PermissionStateChangedAction } from '../actions/device';
|
||||
import {
|
||||
ActionTypes as DeviceActions,
|
||||
ConnectionStateChangedAction,
|
||||
PermissionStateChangedAction,
|
||||
SaveToKeyboardSuccessAction
|
||||
} from '../actions/device';
|
||||
import { AppState, autoWriteUserConfiguration } from '../index';
|
||||
|
||||
@Injectable()
|
||||
export class ApplicationEffects {
|
||||
@@ -68,10 +75,20 @@ export class ApplicationEffects {
|
||||
.map(action => action.payload)
|
||||
.mergeMap((action: Action) => [action, new DismissUndoNotificationAction()]);
|
||||
|
||||
@Effect({dispatch: false}) saveToKeyboardSuccess$ = this.actions$
|
||||
.ofType<SaveToKeyboardSuccessAction>(DeviceActions.SAVE_TO_KEYBOARD_SUCCESS)
|
||||
.withLatestFrom(this.store.select(autoWriteUserConfiguration))
|
||||
.do(([action, autoWriteUserConfig]) => {
|
||||
if (autoWriteUserConfig) {
|
||||
this.appRendererService.exit();
|
||||
}
|
||||
});
|
||||
|
||||
constructor(private actions$: Actions,
|
||||
private notifierService: NotifierService,
|
||||
private appUpdateRendererService: AppUpdateRendererService,
|
||||
private appRendererService: AppRendererService,
|
||||
private logService: LogService) {
|
||||
private logService: LogService,
|
||||
private store: Store<AppState>) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { Action, Store } from '@ngrx/store';
|
||||
import { Actions, Effect, toPayload } from '@ngrx/effects';
|
||||
import { Actions, Effect } from '@ngrx/effects';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import 'rxjs/add/observable/of';
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
HideSaveToKeyboardButton,
|
||||
PermissionStateChangedAction,
|
||||
SaveConfigurationAction,
|
||||
SaveConfigurationReplyAction,
|
||||
SaveToKeyboardSuccessAction,
|
||||
SaveToKeyboardSuccessFailed,
|
||||
SetPrivilegeOnLinuxReplyAction,
|
||||
@@ -113,8 +114,8 @@ export class DeviceEffects {
|
||||
|
||||
@Effect()
|
||||
saveConfigurationReply$: Observable<Action> = this.actions$
|
||||
.ofType(ActionTypes.SAVE_CONFIGURATION_REPLY)
|
||||
.map(toPayload)
|
||||
.ofType<SaveConfigurationReplyAction>(ActionTypes.SAVE_CONFIGURATION_REPLY)
|
||||
.map(action => action.payload)
|
||||
.mergeMap((response: IpcResponse) => {
|
||||
if (response.success) {
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user