diff --git a/electron-projects/ucap-webmessenger-electron/src/index.ts b/electron-projects/ucap-webmessenger-electron/src/index.ts index 313a4149..8925eafe 100644 --- a/electron-projects/ucap-webmessenger-electron/src/index.ts +++ b/electron-projects/ucap-webmessenger-electron/src/index.ts @@ -643,18 +643,32 @@ ipcMain.on( idle.destoryChecker(); idle = null; } + idle = new IdleChecker(appWindow.browserWindow); // default 10min idle.startChecker(); } ); +ipcMain.on( + IdleStateChannel.StopCheck, + (event: IpcMainEvent, ...args: any[]) => { + if (!!idle) { + idle.destoryChecker(); + idle = null; + } + } +); ipcMain.on( IdleStateChannel.ChangeLimitTime, (event: IpcMainEvent, ...args: any[]) => { const limitTime: number = args[0]; if (!!idle) { - idle.resetIdleTime(limitTime); + idle.destoryChecker(); + idle = null; } + + idle = new IdleChecker(appWindow.browserWindow); + idle.resetIdleTime(limitTime); } ); diff --git a/electron-projects/ucap-webmessenger-electron/src/lib/idle-checker.ts b/electron-projects/ucap-webmessenger-electron/src/lib/idle-checker.ts index 3d79ea35..bdaa5f63 100644 --- a/electron-projects/ucap-webmessenger-electron/src/lib/idle-checker.ts +++ b/electron-projects/ucap-webmessenger-electron/src/lib/idle-checker.ts @@ -44,26 +44,23 @@ export class IdleChecker { if (!!this.intervalObject) { clearInterval(this.intervalObject); + this.intervalObject = undefined; } this.limitSec = limitedMin * 60; - // storage.setIdleTimeLimit(limitedMin); - // global.opt_idleTimeLimit = limitedMin; - this.startChecker(); } public startChecker() { if (!this.intervalObject) { - this.intervalObject = setInterval(() => { - this.doCheckIdle(); - }, 1000); + this.intervalObject = setInterval(() => this.doCheckIdle(), 1000); } } public destoryChecker() { if (!!this.intervalObject) { clearInterval(this.intervalObject); + this.intervalObject = undefined; } } } diff --git a/projects/ucap-webmessenger-app/src/app/pages/account/components/login.page.component.ts b/projects/ucap-webmessenger-app/src/app/pages/account/components/login.page.component.ts index d2772ed0..127eb536 100644 --- a/projects/ucap-webmessenger-app/src/app/pages/account/components/login.page.component.ts +++ b/projects/ucap-webmessenger-app/src/app/pages/account/components/login.page.component.ts @@ -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'; @@ -34,6 +34,7 @@ import { LogoutInfo, KEY_LOGOUT_INFO } from '@app/types'; import { AppAuthenticationService } from '@app/services/authentication.service'; import { logoutInitialize } from '@app/store/account/authentication'; import { TranslateService } from '@ngx-translate/core'; +import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native'; @Component({ selector: 'app-page-account-login', @@ -84,6 +85,7 @@ export class LoginPageComponent implements OnInit, OnDestroy { ]; constructor( + @Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService, private store: Store, private router: Router, private translateService: TranslateService, @@ -190,6 +192,11 @@ export class LoginPageComponent implements OnInit, OnDestroy { KEY_LOGOUT_INFO ); + if (!!personLogout) { + // if self logout clear idle check. + this.nativeService.idleStateStop(); + } + if (!!personLogout && !!personLogout.reasonCode) { let msg = this.translateService.instant('accounts.results.doLogout'); switch (personLogout.reasonCode) { diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts index 38d7ce31..2cac0931 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts @@ -234,13 +234,13 @@ export const reducer = createReducer( const roomUserList: RoomUserDetailData[] = []; const roomUserShortList: RoomUserData[] = []; - if (action.userInfoList) { + if (!!action.userInfoList && action.userInfoList.length > 0) { roomUserList.push({ roomSeq: action.roomInfo.roomSeq, userInfos: action.userInfoList }); } - if (action.userInfoShortList) { + if (!!action.userInfoShortList && action.userInfoShortList.length > 0) { roomUserShortList.push({ roomSeq: action.roomInfo.roomSeq, userInfos: action.userInfoShortList @@ -252,12 +252,18 @@ export const reducer = createReducer( room: adapterRoom.upsertOne(action.roomInfo, { ...state.room }), - roomUser: adapterRoomUser.upsertMany(roomUserList, { - ...state.roomUser - }), - roomUserShort: adapterRoomUserShort.upsertMany(roomUserShortList, { - ...state.roomUserShort - }) + roomUser: + roomUserList.length > 0 + ? adapterRoomUser.upsertMany(roomUserList, { + ...state.roomUser + }) + : state.roomUser, + roomUserShort: + roomUserShortList.length > 0 + ? adapterRoomUserShort.upsertMany(roomUserShortList, { + ...state.roomUserShort + }) + : state.roomUserShort }; }), diff --git a/projects/ucap-webmessenger-native-browser/src/lib/services/browser-native.service.ts b/projects/ucap-webmessenger-native-browser/src/lib/services/browser-native.service.ts index 7460f818..50bec0b9 100644 --- a/projects/ucap-webmessenger-native-browser/src/lib/services/browser-native.service.ts +++ b/projects/ucap-webmessenger-native-browser/src/lib/services/browser-native.service.ts @@ -187,13 +187,15 @@ export class BrowserNativeService extends NativeService { }); } - selectSaveFilePath(defaultPath?: string): Promise<{ - canceled: boolean, - filePath: string + selectSaveFilePath( + defaultPath?: string + ): Promise<{ + canceled: boolean; + filePath: string; }> { return new Promise<{ - canceled: boolean, - filePath: string + canceled: boolean; + filePath: string; }>((resolve, reject) => { resolve({ canceled: false, @@ -245,6 +247,8 @@ export class BrowserNativeService extends NativeService { }); } + idleStateStop(): void {} + changeLimitOfIdleState(limitTime: number): void {} chatOpenRoom(): Observable { diff --git a/projects/ucap-webmessenger-native-electron/src/lib/services/electron-native.service.ts b/projects/ucap-webmessenger-native-electron/src/lib/services/electron-native.service.ts index 2b37b986..7f545324 100644 --- a/projects/ucap-webmessenger-native-electron/src/lib/services/electron-native.service.ts +++ b/projects/ucap-webmessenger-native-electron/src/lib/services/electron-native.service.ts @@ -309,13 +309,15 @@ export class ElectronNativeService implements NativeService { }); } - selectSaveFilePath(defaultPath?: string): Promise<{ - canceled: boolean, - filePath: string + selectSaveFilePath( + defaultPath?: string + ): Promise<{ + canceled: boolean; + filePath: string; }> { return new Promise<{ - canceled: boolean, - filePath: string + canceled: boolean; + filePath: string; }>((resolve, reject) => { try { resolve( @@ -409,7 +411,7 @@ export class ElectronNativeService implements NativeService { .asObservable() .pipe(share()); } - + console.log('idleStateChanged'); this.ipcRenderer.send(IdleStateChannel.StartCheck); this.ipcRenderer.on( @@ -421,6 +423,10 @@ export class ElectronNativeService implements NativeService { return this.idleStateChanged$; } + idleStateStop(): void { + this.ipcRenderer.send(IdleStateChannel.StopCheck); + } + changeLimitOfIdleState(limitTime: number): void { this.ipcRenderer.send(IdleStateChannel.ChangeLimitTime, limitTime); } diff --git a/projects/ucap-webmessenger-native-electron/src/lib/types/channel.type.ts b/projects/ucap-webmessenger-native-electron/src/lib/types/channel.type.ts index 8cdf96a8..fdc1801f 100644 --- a/projects/ucap-webmessenger-native-electron/src/lib/types/channel.type.ts +++ b/projects/ucap-webmessenger-native-electron/src/lib/types/channel.type.ts @@ -51,6 +51,7 @@ export enum WindowStateChannel { export enum IdleStateChannel { Changed = 'UCAP::idleState::changed', StartCheck = 'UCAP::idleState::startCheck', + StopCheck = 'UCAP::idleState::stopCheck', ChangeLimitTime = 'UCAP::idleState::changeLimitTime' } diff --git a/projects/ucap-webmessenger-native/src/lib/services/native.service.ts b/projects/ucap-webmessenger-native/src/lib/services/native.service.ts index e456dcb0..ec7962a8 100644 --- a/projects/ucap-webmessenger-native/src/lib/services/native.service.ts +++ b/projects/ucap-webmessenger-native/src/lib/services/native.service.ts @@ -59,9 +59,11 @@ export abstract class NativeService { abstract openTargetItem(filePath?: string): Promise; abstract getPath(name: NativePathName): Promise; abstract selectDirectory(): Promise; - abstract selectSaveFilePath(defaultPath?: string): Promise<{ - canceled: boolean, - filePath: string + abstract selectSaveFilePath( + defaultPath?: string + ): Promise<{ + canceled: boolean; + filePath: string; }>; abstract executeProcess(executableName: string): Promise; @@ -74,6 +76,7 @@ export abstract class NativeService { abstract appExit(): void; abstract idleStateChanged(): Observable; + abstract idleStateStop(): void; abstract changeLimitOfIdleState(limitTime: number): void; abstract chatOpenRoom(): Observable; diff --git a/projects/ucap-webmessenger-protocol-event/src/lib/models/info.ts b/projects/ucap-webmessenger-protocol-event/src/lib/models/info.ts index de6b7c89..c4e9ce20 100644 --- a/projects/ucap-webmessenger-protocol-event/src/lib/models/info.ts +++ b/projects/ucap-webmessenger-protocol-event/src/lib/models/info.ts @@ -42,7 +42,13 @@ export function isForwardable( event: Info, eventInfoStatus: InfoResponse ): 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 ( !!eventInfoStatus && !!eventInfoStatus.validFileBaseSeq &&