윈도우 상태가 최소화, tray, blur 상태일때 read req 하지 않고, focused 되면 그때 현재 방의 read req 하는것으로 수정.
This commit is contained in:
parent
1a34f2582e
commit
5afa223c17
|
@ -17,9 +17,11 @@ import {
|
||||||
import { now } from '../util/now';
|
import { now } from '../util/now';
|
||||||
import { Storage } from '../lib/storage';
|
import { Storage } from '../lib/storage';
|
||||||
import { WindowStateChannel } from '@ucap-webmessenger/native-electron';
|
import { WindowStateChannel } from '@ucap-webmessenger/native-electron';
|
||||||
|
import { Browser } from 'protractor';
|
||||||
|
|
||||||
export class AppWindow {
|
export class AppWindow {
|
||||||
private window: BrowserWindow | null = null;
|
private window: BrowserWindow | null = null;
|
||||||
|
private mainWindowId: number;
|
||||||
|
|
||||||
private eventEmitter = new EventEmitter();
|
private eventEmitter = new EventEmitter();
|
||||||
|
|
||||||
|
@ -74,6 +76,7 @@ export class AppWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.window = new BrowserWindow(windowOptions);
|
this.window = new BrowserWindow(windowOptions);
|
||||||
|
this.mainWindowId = this.window.id;
|
||||||
savedWindowState.manage(this.window);
|
savedWindowState.manage(this.window);
|
||||||
|
|
||||||
let quitting = true;
|
let quitting = true;
|
||||||
|
@ -87,21 +90,27 @@ export class AppWindow {
|
||||||
});
|
});
|
||||||
|
|
||||||
// windows Focus or Blur state detacted.
|
// windows Focus or Blur state detacted.
|
||||||
this.window.on(ElectronBrowserWindowChannel.Focus, () => {
|
this.window.on(ElectronBrowserWindowChannel.Focus, e => {
|
||||||
if (__WIN32__) {
|
const allBrowsers = BrowserWindow.getAllWindows();
|
||||||
// this.window.flashFrame(false);
|
const mainBrowsers = BrowserWindow.fromId(this.mainWindowId);
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!!mainBrowsers && !!mainBrowsers.isFocused()) {
|
||||||
this.window.webContents.send(
|
this.window.webContents.send(
|
||||||
WindowStateChannel.FocuseChanged,
|
WindowStateChannel.FocuseChanged,
|
||||||
ElectronBrowserWindowChannel.Focus
|
ElectronBrowserWindowChannel.Focus
|
||||||
);
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
this.window.on(ElectronBrowserWindowChannel.Blur, () => {
|
this.window.on(ElectronBrowserWindowChannel.Blur, e => {
|
||||||
|
const allBrowsers = BrowserWindow.getAllWindows();
|
||||||
|
const mainBrowsers = BrowserWindow.fromId(this.mainWindowId);
|
||||||
|
|
||||||
|
if (!!mainBrowsers && !mainBrowsers.isFocused()) {
|
||||||
this.window.webContents.send(
|
this.window.webContents.send(
|
||||||
WindowStateChannel.FocuseChanged,
|
WindowStateChannel.FocuseChanged,
|
||||||
ElectronBrowserWindowChannel.Blur
|
ElectronBrowserWindowChannel.Blur
|
||||||
);
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// on macOS, when the user closes the window we really just hide it. This
|
// on macOS, when the user closes the window we really just hide it. This
|
||||||
|
|
|
@ -135,7 +135,11 @@ import {
|
||||||
MassDetailComponent,
|
MassDetailComponent,
|
||||||
MassDetailDialogData
|
MassDetailDialogData
|
||||||
} from '../../dialogs/chat/mass-detail.component';
|
} from '../../dialogs/chat/mass-detail.component';
|
||||||
import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native';
|
import {
|
||||||
|
NativeService,
|
||||||
|
UCAP_NATIVE_SERVICE,
|
||||||
|
WindowState
|
||||||
|
} from '@ucap-webmessenger/native';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -157,6 +161,7 @@ import {
|
||||||
EventDownloadRequest
|
EventDownloadRequest
|
||||||
} from '@ucap-webmessenger/api-message';
|
} from '@ucap-webmessenger/api-message';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
import { ElectronBrowserWindowChannel } from '@ucap-webmessenger/electron-core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-layout-messenger-messages',
|
selector: 'app-layout-messenger-messages',
|
||||||
|
@ -320,6 +325,15 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||||
!!eventList &&
|
!!eventList &&
|
||||||
eventList.length > 0 &&
|
eventList.length > 0 &&
|
||||||
gnbMenuIndex !== MainMenu.Organization
|
gnbMenuIndex !== MainMenu.Organization
|
||||||
|
) {
|
||||||
|
const windowState = this.nativeService.getWindowState();
|
||||||
|
// 윈도우의 상태가 최소화, tray 상태가 아니면서 조직도탭을 보고 있지 않다면,
|
||||||
|
if (
|
||||||
|
!!windowState &&
|
||||||
|
windowState.windowState !== WindowState.Minimized &&
|
||||||
|
windowState.windowState !== WindowState.Hidden &&
|
||||||
|
windowState.windowFocusState ===
|
||||||
|
ElectronBrowserWindowChannel.Focus
|
||||||
) {
|
) {
|
||||||
this.store.dispatch(
|
this.store.dispatch(
|
||||||
EventStore.read({
|
EventStore.read({
|
||||||
|
@ -328,6 +342,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.subscribe();
|
.subscribe();
|
||||||
|
|
|
@ -13,11 +13,23 @@ import { Store, select } from '@ngrx/store';
|
||||||
|
|
||||||
import * as AppStore from '@app/store';
|
import * as AppStore from '@app/store';
|
||||||
import * as ChatStore from '@app/store/messenger/chat';
|
import * as ChatStore from '@app/store/messenger/chat';
|
||||||
|
import * as EventStore from '@app/store/messenger/event';
|
||||||
import * as MessageStore from '@app/store/messenger/message';
|
import * as MessageStore from '@app/store/messenger/message';
|
||||||
import * as StatusStore from '@app/store/messenger/status';
|
import * as StatusStore from '@app/store/messenger/status';
|
||||||
import * as SettingsStore from '@app/store/messenger/settings';
|
import * as SettingsStore from '@app/store/messenger/settings';
|
||||||
import { Observable, Subscription, of, timer, EMPTY } from 'rxjs';
|
import {
|
||||||
import { UCAP_NATIVE_SERVICE, NativeService } from '@ucap-webmessenger/native';
|
Observable,
|
||||||
|
Subscription,
|
||||||
|
of,
|
||||||
|
timer,
|
||||||
|
EMPTY,
|
||||||
|
combineLatest
|
||||||
|
} from 'rxjs';
|
||||||
|
import {
|
||||||
|
UCAP_NATIVE_SERVICE,
|
||||||
|
NativeService,
|
||||||
|
WindowState
|
||||||
|
} from '@ucap-webmessenger/native';
|
||||||
|
|
||||||
import { StatusProtocolService } from '@ucap-webmessenger/protocol-status';
|
import { StatusProtocolService } from '@ucap-webmessenger/protocol-status';
|
||||||
import { StatusType, StatusCode } from '@ucap-webmessenger/core';
|
import { StatusType, StatusCode } from '@ucap-webmessenger/core';
|
||||||
|
@ -53,6 +65,7 @@ import { TranslateService } from '@ngx-translate/core';
|
||||||
import { LeftSideComponent } from '@app/layouts/messenger/components/left-side.component';
|
import { LeftSideComponent } from '@app/layouts/messenger/components/left-side.component';
|
||||||
import { MatDrawer } from '@angular/material/sidenav';
|
import { MatDrawer } from '@angular/material/sidenav';
|
||||||
import { LocationStrategy } from '@angular/common';
|
import { LocationStrategy } from '@angular/common';
|
||||||
|
import { ElectronBrowserWindowChannel } from '@ucap-webmessenger/electron-core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-page-messenger-main',
|
selector: 'app-page-messenger-main',
|
||||||
|
@ -73,6 +86,8 @@ export class MainPageComponent implements OnInit, OnDestroy {
|
||||||
selectedChat$: Observable<string | null>;
|
selectedChat$: Observable<string | null>;
|
||||||
selectedRightDrawer$: Observable<string | null>;
|
selectedRightDrawer$: Observable<string | null>;
|
||||||
idleStateChangedSubscription: Subscription;
|
idleStateChangedSubscription: Subscription;
|
||||||
|
windowFocusChangedSubscription: Subscription;
|
||||||
|
|
||||||
chatOpenRoomSubscription: Subscription;
|
chatOpenRoomSubscription: Subscription;
|
||||||
msgOpenMessageSubscription: Subscription;
|
msgOpenMessageSubscription: Subscription;
|
||||||
myIdleCheckTimeSubscription: Subscription;
|
myIdleCheckTimeSubscription: Subscription;
|
||||||
|
@ -139,6 +154,38 @@ export class MainPageComponent implements OnInit, OnDestroy {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.windowFocusChangedSubscription = combineLatest([
|
||||||
|
this.nativeService.windowFocusChanged(),
|
||||||
|
this.store.pipe(select(AppStore.MessengerSelector.RoomSelector.roomInfo)),
|
||||||
|
this.store.pipe(
|
||||||
|
select(AppStore.MessengerSelector.SettingsSelector.gnbMenuIndex)
|
||||||
|
),
|
||||||
|
this.store.pipe(
|
||||||
|
select(AppStore.MessengerSelector.EventSelector.selectAllInfoList)
|
||||||
|
)
|
||||||
|
])
|
||||||
|
.pipe(
|
||||||
|
map(([windowFocusState, roomInfo, gnbMenuIndex, eventList]) => {
|
||||||
|
if (windowFocusState === ElectronBrowserWindowChannel.Focus) {
|
||||||
|
if (
|
||||||
|
!!roomInfo &&
|
||||||
|
!!roomInfo.roomSeq &&
|
||||||
|
!!eventList &&
|
||||||
|
eventList.length > 0 &&
|
||||||
|
gnbMenuIndex !== MainMenu.Organization
|
||||||
|
) {
|
||||||
|
this.store.dispatch(
|
||||||
|
EventStore.read({
|
||||||
|
roomSeq: roomInfo.roomSeq,
|
||||||
|
lastReadSeq: eventList[eventList.length - 1].seq
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe();
|
||||||
|
|
||||||
this.leftSideDrawerSubscription = this.store
|
this.leftSideDrawerSubscription = this.store
|
||||||
.pipe(
|
.pipe(
|
||||||
select(AppStore.MessengerSelector.ChatSelector.selectLeftSideDrawer)
|
select(AppStore.MessengerSelector.ChatSelector.selectLeftSideDrawer)
|
||||||
|
@ -270,6 +317,9 @@ export class MainPageComponent implements OnInit, OnDestroy {
|
||||||
if (!!this.idleStateChangedSubscription) {
|
if (!!this.idleStateChangedSubscription) {
|
||||||
this.idleStateChangedSubscription.unsubscribe();
|
this.idleStateChangedSubscription.unsubscribe();
|
||||||
}
|
}
|
||||||
|
if (!!this.windowFocusChangedSubscription) {
|
||||||
|
this.windowFocusChangedSubscription.unsubscribe();
|
||||||
|
}
|
||||||
|
|
||||||
if (!!this.chatOpenRoomSubscription) {
|
if (!!this.chatOpenRoomSubscription) {
|
||||||
this.chatOpenRoomSubscription.unsubscribe();
|
this.chatOpenRoomSubscription.unsubscribe();
|
||||||
|
|
|
@ -274,6 +274,7 @@ export class AppNotificationService {
|
||||||
'Notification::eventProtocolService::SendNotification',
|
'Notification::eventProtocolService::SendNotification',
|
||||||
noti
|
noti
|
||||||
);
|
);
|
||||||
|
const windowState = this.nativeService.getWindowState();
|
||||||
|
|
||||||
// Event..
|
// Event..
|
||||||
this.store.dispatch(
|
this.store.dispatch(
|
||||||
|
@ -283,13 +284,29 @@ export class AppNotificationService {
|
||||||
);
|
);
|
||||||
|
|
||||||
// unread count..
|
// unread count..
|
||||||
|
let doReadRequest = false;
|
||||||
|
|
||||||
|
// 현재 방이 열려 있고,
|
||||||
if (
|
if (
|
||||||
!!curRoomInfo &&
|
!!curRoomInfo &&
|
||||||
!!curRoomInfo.roomSeq &&
|
!!curRoomInfo.roomSeq &&
|
||||||
curRoomInfo.roomSeq === noti.roomSeq &&
|
curRoomInfo.roomSeq === noti.roomSeq
|
||||||
|
) {
|
||||||
|
// 윈도우의 상태가 최소화, tray 상태가 아니면서 조직도탭을 보고 있지 않다면,
|
||||||
|
if (
|
||||||
|
!!windowState &&
|
||||||
|
windowState.windowState !== WindowState.Minimized &&
|
||||||
|
windowState.windowState !== WindowState.Hidden &&
|
||||||
|
windowState.windowFocusState ===
|
||||||
|
ElectronBrowserWindowChannel.Focus &&
|
||||||
gnbMenuIndex !== MainMenu.Organization
|
gnbMenuIndex !== MainMenu.Organization
|
||||||
) {
|
) {
|
||||||
// 현재 방이 열려 있고, 조직도탭을 보고 있지 않다면 대화방을 보고 있다고 판단하고 event_read_req 한다.
|
// 대화방을 보고 있다고 판단하고 event_read_req 한다.
|
||||||
|
doReadRequest = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doReadRequest) {
|
||||||
this.store.dispatch(
|
this.store.dispatch(
|
||||||
EventStore.read({
|
EventStore.read({
|
||||||
roomSeq: noti.roomSeq,
|
roomSeq: noti.roomSeq,
|
||||||
|
@ -326,8 +343,6 @@ export class AppNotificationService {
|
||||||
if (notiOrRes.SSVC_TYPE === SSVC_TYPE_EVENT_SEND_NOTI) {
|
if (notiOrRes.SSVC_TYPE === SSVC_TYPE_EVENT_SEND_NOTI) {
|
||||||
let doNoti = true;
|
let doNoti = true;
|
||||||
|
|
||||||
const windowState = this.nativeService.getWindowState();
|
|
||||||
|
|
||||||
// 현재 열려 있는 방일경우 노티 안함.
|
// 현재 열려 있는 방일경우 노티 안함.
|
||||||
if (
|
if (
|
||||||
!!curRoomInfo &&
|
!!curRoomInfo &&
|
||||||
|
|
|
@ -906,15 +906,9 @@ export class Effects {
|
||||||
withLatestFrom(
|
withLatestFrom(
|
||||||
this.store.pipe(
|
this.store.pipe(
|
||||||
select((state: any) => state.messenger.room.roomInfo as RoomInfo)
|
select((state: any) => state.messenger.room.roomInfo as RoomInfo)
|
||||||
),
|
|
||||||
this.store.pipe(
|
|
||||||
select(
|
|
||||||
(state: any) =>
|
|
||||||
state.messenger.sync.room.entities as Dictionary<RoomInfo>
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
tap(([action, roomInfo, trgtRoomInfos]) => {
|
tap(([action, roomInfo]) => {
|
||||||
// opened room :: event add
|
// opened room :: event add
|
||||||
if (!!roomInfo && roomInfo.roomSeq === action.roomSeq) {
|
if (!!roomInfo && roomInfo.roomSeq === action.roomSeq) {
|
||||||
this.store.dispatch(appendInfoList({ info: action.info }));
|
this.store.dispatch(appendInfoList({ info: action.info }));
|
||||||
|
|
|
@ -226,6 +226,21 @@ export class BrowserNativeService extends NativeService {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
windowFocusChanged(): Observable<
|
||||||
|
ElectronBrowserWindowChannel.Focus | ElectronBrowserWindowChannel.Blur
|
||||||
|
> {
|
||||||
|
return new Observable<
|
||||||
|
ElectronBrowserWindowChannel.Focus | ElectronBrowserWindowChannel.Blur
|
||||||
|
>(subscriber => {
|
||||||
|
try {
|
||||||
|
subscriber.next(ElectronBrowserWindowChannel.Focus);
|
||||||
|
} catch (error) {
|
||||||
|
subscriber.error(error);
|
||||||
|
} finally {
|
||||||
|
subscriber.complete();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
windowClose(): void {}
|
windowClose(): void {}
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,13 @@ export class ElectronNativeService implements NativeService {
|
||||||
private windowStateChangedSubject: Subject<WindowState> | null = null;
|
private windowStateChangedSubject: Subject<WindowState> | null = null;
|
||||||
private windowStateChanged$: Observable<WindowState> | null = null;
|
private windowStateChanged$: Observable<WindowState> | null = null;
|
||||||
|
|
||||||
|
private windowFocusChangedSubject: Subject<
|
||||||
|
ElectronBrowserWindowChannel.Focus | ElectronBrowserWindowChannel.Blur
|
||||||
|
> | null = null;
|
||||||
|
private windowFocusChanged$: Observable<
|
||||||
|
ElectronBrowserWindowChannel.Focus | ElectronBrowserWindowChannel.Blur
|
||||||
|
> | null = null;
|
||||||
|
|
||||||
private idleStateChangedSubject: Subject<WindowIdle> | null = null;
|
private idleStateChangedSubject: Subject<WindowIdle> | null = null;
|
||||||
private idleStateChanged$: Observable<WindowIdle> | null = null;
|
private idleStateChanged$: Observable<WindowIdle> | null = null;
|
||||||
|
|
||||||
|
@ -374,6 +381,32 @@ export class ElectronNativeService implements NativeService {
|
||||||
);
|
);
|
||||||
return this.windowStateChanged$;
|
return this.windowStateChanged$;
|
||||||
}
|
}
|
||||||
|
windowFocusChanged(): Observable<
|
||||||
|
ElectronBrowserWindowChannel.Focus | ElectronBrowserWindowChannel.Blur
|
||||||
|
> {
|
||||||
|
if (!this.windowFocusChangedSubject) {
|
||||||
|
this.windowFocusChangedSubject = new Subject<
|
||||||
|
ElectronBrowserWindowChannel.Focus | ElectronBrowserWindowChannel.Blur
|
||||||
|
>();
|
||||||
|
this.windowFocusChanged$ = this.windowFocusChangedSubject
|
||||||
|
.asObservable()
|
||||||
|
.pipe(share());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.ipcRenderer.on(
|
||||||
|
WindowStateChannel.FocuseChanged,
|
||||||
|
(
|
||||||
|
event: any,
|
||||||
|
status:
|
||||||
|
| ElectronBrowserWindowChannel.Focus
|
||||||
|
| ElectronBrowserWindowChannel.Blur
|
||||||
|
) => {
|
||||||
|
this.windowFocusState = status;
|
||||||
|
this.windowFocusChangedSubject.next(status);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return this.windowFocusChanged$;
|
||||||
|
}
|
||||||
|
|
||||||
windowClose(): void {
|
windowClose(): void {
|
||||||
const currentWindow = this.remote.getCurrentWindow();
|
const currentWindow = this.remote.getCurrentWindow();
|
||||||
|
@ -552,17 +585,5 @@ export class ElectronNativeService implements NativeService {
|
||||||
this.shell = (window as any).require('electron').shell;
|
this.shell = (window as any).require('electron').shell;
|
||||||
this.webFrame = (window as any).require('electron').webFrame;
|
this.webFrame = (window as any).require('electron').webFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ipcRenderer.on(
|
|
||||||
WindowStateChannel.FocuseChanged,
|
|
||||||
(
|
|
||||||
event: any,
|
|
||||||
status:
|
|
||||||
| ElectronBrowserWindowChannel.Focus
|
|
||||||
| ElectronBrowserWindowChannel.Blur
|
|
||||||
) => {
|
|
||||||
this.windowFocusState = status;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,9 @@ export abstract class NativeService {
|
||||||
abstract onFlashFlame(): void;
|
abstract onFlashFlame(): void;
|
||||||
abstract offFlashFlame(): void;
|
abstract offFlashFlame(): void;
|
||||||
abstract windowStateChanged(): Observable<WindowState>;
|
abstract windowStateChanged(): Observable<WindowState>;
|
||||||
|
abstract windowFocusChanged(): Observable<
|
||||||
|
ElectronBrowserWindowChannel.Focus | ElectronBrowserWindowChannel.Blur
|
||||||
|
>;
|
||||||
abstract windowClose(): void;
|
abstract windowClose(): void;
|
||||||
abstract windowMinimize(): void;
|
abstract windowMinimize(): void;
|
||||||
abstract windowMaximize(): void;
|
abstract windowMaximize(): void;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user