This commit is contained in:
richard-loafle 2020-01-31 14:47:21 +09:00
commit 1ed7a2402d
9 changed files with 75 additions and 31 deletions

View File

@ -652,18 +652,32 @@ ipcMain.on(
idle.destoryChecker(); idle.destoryChecker();
idle = null; idle = null;
} }
idle = new IdleChecker(appWindow.browserWindow); // default 10min idle = new IdleChecker(appWindow.browserWindow); // default 10min
idle.startChecker(); idle.startChecker();
} }
); );
ipcMain.on(
IdleStateChannel.StopCheck,
(event: IpcMainEvent, ...args: any[]) => {
if (!!idle) {
idle.destoryChecker();
idle = null;
}
}
);
ipcMain.on( ipcMain.on(
IdleStateChannel.ChangeLimitTime, IdleStateChannel.ChangeLimitTime,
(event: IpcMainEvent, ...args: any[]) => { (event: IpcMainEvent, ...args: any[]) => {
const limitTime: number = args[0]; const limitTime: number = args[0];
if (!!idle) { if (!!idle) {
idle.resetIdleTime(limitTime); idle.destoryChecker();
idle = null;
} }
idle = new IdleChecker(appWindow.browserWindow);
idle.resetIdleTime(limitTime);
} }
); );

View File

@ -44,26 +44,23 @@ export class IdleChecker {
if (!!this.intervalObject) { if (!!this.intervalObject) {
clearInterval(this.intervalObject); clearInterval(this.intervalObject);
this.intervalObject = undefined;
} }
this.limitSec = limitedMin * 60; this.limitSec = limitedMin * 60;
// storage.setIdleTimeLimit(limitedMin);
// global.opt_idleTimeLimit = limitedMin;
this.startChecker(); this.startChecker();
} }
public startChecker() { public startChecker() {
if (!this.intervalObject) { if (!this.intervalObject) {
this.intervalObject = setInterval(() => { this.intervalObject = setInterval(() => this.doCheckIdle(), 1000);
this.doCheckIdle();
}, 1000);
} }
} }
public destoryChecker() { public destoryChecker() {
if (!!this.intervalObject) { if (!!this.intervalObject) {
clearInterval(this.intervalObject); clearInterval(this.intervalObject);
this.intervalObject = undefined;
} }
} }
} }

View File

@ -1,4 +1,4 @@
import { Component, OnInit, OnDestroy } from '@angular/core'; import { Component, OnInit, OnDestroy, Inject } from '@angular/core';
import { Store, select } from '@ngrx/store'; import { Store, select } from '@ngrx/store';
@ -34,6 +34,7 @@ import { LogoutInfo, KEY_LOGOUT_INFO } from '@app/types';
import { AppAuthenticationService } from '@app/services/authentication.service'; import { AppAuthenticationService } from '@app/services/authentication.service';
import { logoutInitialize } from '@app/store/account/authentication'; import { logoutInitialize } from '@app/store/account/authentication';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native';
@Component({ @Component({
selector: 'app-page-account-login', selector: 'app-page-account-login',
@ -84,6 +85,7 @@ export class LoginPageComponent implements OnInit, OnDestroy {
]; ];
constructor( constructor(
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
private store: Store<any>, private store: Store<any>,
private router: Router, private router: Router,
private translateService: TranslateService, private translateService: TranslateService,
@ -190,6 +192,11 @@ export class LoginPageComponent implements OnInit, OnDestroy {
KEY_LOGOUT_INFO KEY_LOGOUT_INFO
); );
if (!!personLogout) {
// if self logout clear idle check.
this.nativeService.idleStateStop();
}
if (!!personLogout && !!personLogout.reasonCode) { if (!!personLogout && !!personLogout.reasonCode) {
let msg = this.translateService.instant('accounts.results.doLogout'); let msg = this.translateService.instant('accounts.results.doLogout');
switch (personLogout.reasonCode) { switch (personLogout.reasonCode) {

View File

@ -234,13 +234,13 @@ export const reducer = createReducer(
const roomUserList: RoomUserDetailData[] = []; const roomUserList: RoomUserDetailData[] = [];
const roomUserShortList: RoomUserData[] = []; const roomUserShortList: RoomUserData[] = [];
if (action.userInfoList) { if (!!action.userInfoList && action.userInfoList.length > 0) {
roomUserList.push({ roomUserList.push({
roomSeq: action.roomInfo.roomSeq, roomSeq: action.roomInfo.roomSeq,
userInfos: action.userInfoList userInfos: action.userInfoList
}); });
} }
if (action.userInfoShortList) { if (!!action.userInfoShortList && action.userInfoShortList.length > 0) {
roomUserShortList.push({ roomUserShortList.push({
roomSeq: action.roomInfo.roomSeq, roomSeq: action.roomInfo.roomSeq,
userInfos: action.userInfoShortList userInfos: action.userInfoShortList
@ -252,12 +252,18 @@ export const reducer = createReducer(
room: adapterRoom.upsertOne(action.roomInfo, { room: adapterRoom.upsertOne(action.roomInfo, {
...state.room ...state.room
}), }),
roomUser: adapterRoomUser.upsertMany(roomUserList, { roomUser:
roomUserList.length > 0
? adapterRoomUser.upsertMany(roomUserList, {
...state.roomUser ...state.roomUser
}), })
roomUserShort: adapterRoomUserShort.upsertMany(roomUserShortList, { : state.roomUser,
roomUserShort:
roomUserShortList.length > 0
? adapterRoomUserShort.upsertMany(roomUserShortList, {
...state.roomUserShort ...state.roomUserShort
}) })
: state.roomUserShort
}; };
}), }),

View File

@ -187,13 +187,15 @@ export class BrowserNativeService extends NativeService {
}); });
} }
selectSaveFilePath(defaultPath?: string): Promise<{ selectSaveFilePath(
canceled: boolean, defaultPath?: string
filePath: string ): Promise<{
canceled: boolean;
filePath: string;
}> { }> {
return new Promise<{ return new Promise<{
canceled: boolean, canceled: boolean;
filePath: string filePath: string;
}>((resolve, reject) => { }>((resolve, reject) => {
resolve({ resolve({
canceled: false, canceled: false,
@ -245,6 +247,8 @@ export class BrowserNativeService extends NativeService {
}); });
} }
idleStateStop(): void {}
changeLimitOfIdleState(limitTime: number): void {} changeLimitOfIdleState(limitTime: number): void {}
chatOpenRoom(): Observable<string> { chatOpenRoom(): Observable<string> {

View File

@ -309,13 +309,15 @@ export class ElectronNativeService implements NativeService {
}); });
} }
selectSaveFilePath(defaultPath?: string): Promise<{ selectSaveFilePath(
canceled: boolean, defaultPath?: string
filePath: string ): Promise<{
canceled: boolean;
filePath: string;
}> { }> {
return new Promise<{ return new Promise<{
canceled: boolean, canceled: boolean;
filePath: string filePath: string;
}>((resolve, reject) => { }>((resolve, reject) => {
try { try {
resolve( resolve(
@ -409,7 +411,7 @@ export class ElectronNativeService implements NativeService {
.asObservable() .asObservable()
.pipe(share()); .pipe(share());
} }
console.log('idleStateChanged');
this.ipcRenderer.send(IdleStateChannel.StartCheck); this.ipcRenderer.send(IdleStateChannel.StartCheck);
this.ipcRenderer.on( this.ipcRenderer.on(
@ -421,6 +423,10 @@ export class ElectronNativeService implements NativeService {
return this.idleStateChanged$; return this.idleStateChanged$;
} }
idleStateStop(): void {
this.ipcRenderer.send(IdleStateChannel.StopCheck);
}
changeLimitOfIdleState(limitTime: number): void { changeLimitOfIdleState(limitTime: number): void {
this.ipcRenderer.send(IdleStateChannel.ChangeLimitTime, limitTime); this.ipcRenderer.send(IdleStateChannel.ChangeLimitTime, limitTime);
} }

View File

@ -51,6 +51,7 @@ export enum WindowStateChannel {
export enum IdleStateChannel { export enum IdleStateChannel {
Changed = 'UCAP::idleState::changed', Changed = 'UCAP::idleState::changed',
StartCheck = 'UCAP::idleState::startCheck', StartCheck = 'UCAP::idleState::startCheck',
StopCheck = 'UCAP::idleState::stopCheck',
ChangeLimitTime = 'UCAP::idleState::changeLimitTime' ChangeLimitTime = 'UCAP::idleState::changeLimitTime'
} }

View File

@ -59,9 +59,11 @@ export abstract class NativeService {
abstract openTargetItem(filePath?: string): Promise<boolean>; abstract openTargetItem(filePath?: string): Promise<boolean>;
abstract getPath(name: NativePathName): Promise<string>; abstract getPath(name: NativePathName): Promise<string>;
abstract selectDirectory(): Promise<string>; abstract selectDirectory(): Promise<string>;
abstract selectSaveFilePath(defaultPath?: string): Promise<{ abstract selectSaveFilePath(
canceled: boolean, defaultPath?: string
filePath: string ): Promise<{
canceled: boolean;
filePath: string;
}>; }>;
abstract executeProcess(executableName: string): Promise<number>; abstract executeProcess(executableName: string): Promise<number>;
@ -74,6 +76,7 @@ export abstract class NativeService {
abstract appExit(): void; abstract appExit(): void;
abstract idleStateChanged(): Observable<WindowIdle>; abstract idleStateChanged(): Observable<WindowIdle>;
abstract idleStateStop(): void;
abstract changeLimitOfIdleState(limitTime: number): void; abstract changeLimitOfIdleState(limitTime: number): void;
abstract chatOpenRoom(): Observable<string>; abstract chatOpenRoom(): Observable<string>;

View File

@ -42,7 +42,13 @@ export function isForwardable(
event: Info, event: Info,
eventInfoStatus: InfoResponse eventInfoStatus: InfoResponse
): boolean { ): boolean {
if (event.type === EventType.File) { if (
event.type === EventType.Plan ||
event.type === EventType.AllimTms ||
event.type === EventType.AllimElephant
) {
return false;
} else if (event.type === EventType.File) {
if ( if (
!!eventInfoStatus && !!eventInfoStatus &&
!!eventInfoStatus.validFileBaseSeq && !!eventInfoStatus.validFileBaseSeq &&