exit from app
This commit is contained in:
@@ -3,7 +3,7 @@ import { UhkHidDevice } from 'uhk-usb';
|
|||||||
import { readFile } from 'fs';
|
import { readFile } from 'fs';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
|
||||||
import { AppStartInfo, CommandLineArgs, IpcEvents, LogService } from 'uhk-common';
|
import { AppStartInfo, IpcEvents, LogService } from 'uhk-common';
|
||||||
import { MainServiceBase } from './main-service-base';
|
import { MainServiceBase } from './main-service-base';
|
||||||
import { DeviceService } from './device.service';
|
import { DeviceService } from './device.service';
|
||||||
import { CommandLineInputs } from '../models/command-line-inputs';
|
import { CommandLineInputs } from '../models/command-line-inputs';
|
||||||
@@ -17,6 +17,7 @@ export class AppService extends MainServiceBase {
|
|||||||
super(logService, win);
|
super(logService, win);
|
||||||
|
|
||||||
ipcMain.on(IpcEvents.app.getAppStartInfo, this.handleAppStartInfo.bind(this));
|
ipcMain.on(IpcEvents.app.getAppStartInfo, this.handleAppStartInfo.bind(this));
|
||||||
|
ipcMain.on(IpcEvents.app.exit, this.exit.bind(this));
|
||||||
logService.info('[AppService] init success');
|
logService.info('[AppService] init success');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,4 +62,9 @@ export class AppService extends MainServiceBase {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private exit() {
|
||||||
|
this.logService.info('[AppService] exit');
|
||||||
|
this.win.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ class App {
|
|||||||
public static readonly appStarted = 'app-started';
|
public static readonly appStarted = 'app-started';
|
||||||
public static readonly getAppStartInfo = 'app-get-start-info';
|
public static readonly getAppStartInfo = 'app-get-start-info';
|
||||||
public static readonly getAppStartInfoReply = 'app-get-start-info-reply';
|
public static readonly getAppStartInfoReply = 'app-get-start-info-reply';
|
||||||
|
public static readonly exit = 'app-exit';
|
||||||
}
|
}
|
||||||
|
|
||||||
class AutoUpdate {
|
class AutoUpdate {
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ export class AppRendererService {
|
|||||||
this.ipcRenderer.send(IpcEvents.app.getAppStartInfo);
|
this.ipcRenderer.send(IpcEvents.app.getAppStartInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exit() {
|
||||||
|
this.logService.info('[AppRendererService] exit');
|
||||||
|
this.ipcRenderer.send(IpcEvents.app.exit);
|
||||||
|
}
|
||||||
|
|
||||||
private registerEvents() {
|
private registerEvents() {
|
||||||
this.ipcRenderer.on(IpcEvents.app.getAppStartInfoReply, (event: string, arg: AppStartInfo) => {
|
this.ipcRenderer.on(IpcEvents.app.getAppStartInfoReply, (event: string, arg: AppStartInfo) => {
|
||||||
this.dispachStoreAction(new ProcessAppStartInfoAction(arg));
|
this.dispachStoreAction(new ProcessAppStartInfoAction(arg));
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Action } from '@ngrx/store';
|
import { Action, Store } from '@ngrx/store';
|
||||||
import { Actions, Effect } from '@ngrx/effects';
|
import { Actions, Effect } from '@ngrx/effects';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { NotifierService } from 'angular-notifier';
|
import { NotifierService } from 'angular-notifier';
|
||||||
@@ -13,16 +13,23 @@ import 'rxjs/add/operator/catch';
|
|||||||
import { AppStartInfo, LogService, Notification, NotificationType } from 'uhk-common';
|
import { AppStartInfo, LogService, Notification, NotificationType } from 'uhk-common';
|
||||||
import {
|
import {
|
||||||
ActionTypes,
|
ActionTypes,
|
||||||
|
ApplyCommandLineArgsAction,
|
||||||
AppStartedAction,
|
AppStartedAction,
|
||||||
DismissUndoNotificationAction,
|
DismissUndoNotificationAction,
|
||||||
ProcessAppStartInfoAction,
|
ProcessAppStartInfoAction,
|
||||||
ShowNotificationAction,
|
ShowNotificationAction,
|
||||||
ApplyCommandLineArgsAction,
|
UndoLastAction,
|
||||||
UndoLastAction, UpdateAgentVersionInformationAction
|
UpdateAgentVersionInformationAction
|
||||||
} from '../actions/app';
|
} from '../actions/app';
|
||||||
import { AppRendererService } from '../../services/app-renderer.service';
|
import { AppRendererService } from '../../services/app-renderer.service';
|
||||||
import { AppUpdateRendererService } from '../../services/app-update-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()
|
@Injectable()
|
||||||
export class ApplicationEffects {
|
export class ApplicationEffects {
|
||||||
@@ -68,10 +75,20 @@ export class ApplicationEffects {
|
|||||||
.map(action => action.payload)
|
.map(action => action.payload)
|
||||||
.mergeMap((action: Action) => [action, new DismissUndoNotificationAction()]);
|
.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,
|
constructor(private actions$: Actions,
|
||||||
private notifierService: NotifierService,
|
private notifierService: NotifierService,
|
||||||
private appUpdateRendererService: AppUpdateRendererService,
|
private appUpdateRendererService: AppUpdateRendererService,
|
||||||
private appRendererService: AppRendererService,
|
private appRendererService: AppRendererService,
|
||||||
private logService: LogService) {
|
private logService: LogService,
|
||||||
|
private store: Store<AppState>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { Action, Store } from '@ngrx/store';
|
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 { Observable } from 'rxjs/Observable';
|
||||||
|
|
||||||
import 'rxjs/add/observable/of';
|
import 'rxjs/add/observable/of';
|
||||||
@@ -20,6 +20,7 @@ import {
|
|||||||
HideSaveToKeyboardButton,
|
HideSaveToKeyboardButton,
|
||||||
PermissionStateChangedAction,
|
PermissionStateChangedAction,
|
||||||
SaveConfigurationAction,
|
SaveConfigurationAction,
|
||||||
|
SaveConfigurationReplyAction,
|
||||||
SaveToKeyboardSuccessAction,
|
SaveToKeyboardSuccessAction,
|
||||||
SaveToKeyboardSuccessFailed,
|
SaveToKeyboardSuccessFailed,
|
||||||
SetPrivilegeOnLinuxReplyAction,
|
SetPrivilegeOnLinuxReplyAction,
|
||||||
@@ -113,8 +114,8 @@ export class DeviceEffects {
|
|||||||
|
|
||||||
@Effect()
|
@Effect()
|
||||||
saveConfigurationReply$: Observable<Action> = this.actions$
|
saveConfigurationReply$: Observable<Action> = this.actions$
|
||||||
.ofType(ActionTypes.SAVE_CONFIGURATION_REPLY)
|
.ofType<SaveConfigurationReplyAction>(ActionTypes.SAVE_CONFIGURATION_REPLY)
|
||||||
.map(toPayload)
|
.map(action => action.payload)
|
||||||
.mergeMap((response: IpcResponse) => {
|
.mergeMap((response: IpcResponse) => {
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
return [
|
return [
|
||||||
|
|||||||
Reference in New Issue
Block a user