윈도우 백그라운드에 있을때 알림 주는 로직으로 개선 (미완료 1차 커밋)
This commit is contained in:
parent
5ba16d1ac0
commit
9323a2af0d
|
@ -16,6 +16,7 @@ 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';
|
||||||
|
|
||||||
export class AppWindow {
|
export class AppWindow {
|
||||||
private window: BrowserWindow | null = null;
|
private window: BrowserWindow | null = null;
|
||||||
|
@ -84,12 +85,18 @@ export class AppWindow {
|
||||||
event.returnValue = true;
|
event.returnValue = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// windows Focus or Blur state detacted.
|
||||||
this.window.on(ElectronBrowserWindowChannel.Focus, () => {
|
this.window.on(ElectronBrowserWindowChannel.Focus, () => {
|
||||||
console.log('window got focus');
|
this.window.webContents.send(
|
||||||
|
WindowStateChannel.FocuseChanged,
|
||||||
|
ElectronBrowserWindowChannel.Focus
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.window.on(ElectronBrowserWindowChannel.Blur, () => {
|
this.window.on(ElectronBrowserWindowChannel.Blur, () => {
|
||||||
console.log('window blur');
|
this.window.webContents.send(
|
||||||
|
WindowStateChannel.FocuseChanged,
|
||||||
|
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
|
||||||
|
|
|
@ -130,6 +130,7 @@ import {
|
||||||
ChatSetting
|
ChatSetting
|
||||||
} from '@ucap-webmessenger/ui-settings';
|
} from '@ucap-webmessenger/ui-settings';
|
||||||
import clone from 'clone';
|
import clone from 'clone';
|
||||||
|
import { ElectronBrowserWindowChannel } from '@ucap-webmessenger/electron-core';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AppNotificationService {
|
export class AppNotificationService {
|
||||||
|
@ -232,14 +233,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;
|
||||||
|
|
||||||
// 방별 알림이 꺼져 있으면 노티 안함.
|
|
||||||
if (
|
|
||||||
!!roomList[noti.roomSeq] &&
|
|
||||||
!roomList[noti.roomSeq].receiveAlarm
|
|
||||||
) {
|
|
||||||
doNoti = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const windowState = this.nativeService.getWindowState();
|
const windowState = this.nativeService.getWindowState();
|
||||||
|
|
||||||
// 현재 열려 있는 방일경우 노티 안함.
|
// 현재 열려 있는 방일경우 노티 안함.
|
||||||
|
@ -248,8 +241,27 @@ export class AppNotificationService {
|
||||||
!!curRoomInfo.roomSeq &&
|
!!curRoomInfo.roomSeq &&
|
||||||
curRoomInfo.roomSeq === noti.roomSeq &&
|
curRoomInfo.roomSeq === noti.roomSeq &&
|
||||||
!!windowState &&
|
!!windowState &&
|
||||||
windowState !== WindowState.Minimized &&
|
windowState.windowState !== WindowState.Minimized &&
|
||||||
windowState !== WindowState.Hidden
|
windowState.windowState !== WindowState.Hidden
|
||||||
|
) {
|
||||||
|
doNoti = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// // 포커스 아웃일때 무조건 노티.
|
||||||
|
// // Case 1 : 단순 포커스 아웃.
|
||||||
|
// // Case 2 : hidden 시 포커스 인 상태이지만 위에서 필터링 됨.
|
||||||
|
// console.log(windowState);
|
||||||
|
// if (
|
||||||
|
// windowState.windowFocusState !==
|
||||||
|
// ElectronBrowserWindowChannel.Focus
|
||||||
|
// ) {
|
||||||
|
// doNoti = true;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 방별 알림이 꺼져 있으면 노티 안함. > 우선순위 최상위.
|
||||||
|
if (
|
||||||
|
!!roomList[noti.roomSeq] &&
|
||||||
|
!roomList[noti.roomSeq].receiveAlarm
|
||||||
) {
|
) {
|
||||||
doNoti = false;
|
doNoti = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import { TranslateLoaderService } from '../translate/browser-loader';
|
||||||
import { NotificationService } from '../notification/notification.service';
|
import { NotificationService } from '../notification/notification.service';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { FileUtil, StatusCode } from '@ucap-webmessenger/core';
|
import { FileUtil, StatusCode } from '@ucap-webmessenger/core';
|
||||||
|
import { ElectronBrowserWindowChannel } from '@ucap-webmessenger/electron-core';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
|
@ -229,8 +230,16 @@ export class BrowserNativeService extends NativeService {
|
||||||
windowMinimize(): void {}
|
windowMinimize(): void {}
|
||||||
|
|
||||||
windowMaximize(): void {}
|
windowMaximize(): void {}
|
||||||
getWindowState(): WindowState {
|
getWindowState(): {
|
||||||
return WindowState.Normal;
|
windowState: WindowState;
|
||||||
|
windowFocusState:
|
||||||
|
| ElectronBrowserWindowChannel.Focus
|
||||||
|
| ElectronBrowserWindowChannel.Blur;
|
||||||
|
} {
|
||||||
|
return {
|
||||||
|
windowState: WindowState.Normal,
|
||||||
|
windowFocusState: ElectronBrowserWindowChannel.Focus
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
appExit(): void {}
|
appExit(): void {}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import { Injectable } from '@angular/core';
|
||||||
import { TranslateLoaderService } from '../translate/electron-loader';
|
import { TranslateLoaderService } from '../translate/electron-loader';
|
||||||
import { TranslateLoader } from '@ngx-translate/core';
|
import { TranslateLoader } from '@ngx-translate/core';
|
||||||
import { StatusCode } from '@ucap-webmessenger/core';
|
import { StatusCode } from '@ucap-webmessenger/core';
|
||||||
|
import { ElectronBrowserWindowChannel } from '@ucap-webmessenger/electron-core';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
|
@ -65,6 +66,10 @@ export class ElectronNativeService implements NativeService {
|
||||||
private backgroundCheckForUpdatesSubject: Subject<UpdateInfo> | null = null;
|
private backgroundCheckForUpdatesSubject: Subject<UpdateInfo> | null = null;
|
||||||
private backgroundCheckForUpdates$: Observable<UpdateInfo> | null = null;
|
private backgroundCheckForUpdates$: Observable<UpdateInfo> | null = null;
|
||||||
|
|
||||||
|
private windowFocusState:
|
||||||
|
| ElectronBrowserWindowChannel.Focus
|
||||||
|
| ElectronBrowserWindowChannel.Blur;
|
||||||
|
|
||||||
type(): NativeType {
|
type(): NativeType {
|
||||||
return NativeType.Electron;
|
return NativeType.Electron;
|
||||||
}
|
}
|
||||||
|
@ -395,20 +400,29 @@ export class ElectronNativeService implements NativeService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getWindowState(): WindowState {
|
getWindowState(): {
|
||||||
|
windowState: WindowState;
|
||||||
|
windowFocusState:
|
||||||
|
| ElectronBrowserWindowChannel.Focus
|
||||||
|
| ElectronBrowserWindowChannel.Blur;
|
||||||
|
} {
|
||||||
|
let windowState = WindowState.Normal;
|
||||||
if (!remote.getCurrentWindow().isVisible()) {
|
if (!remote.getCurrentWindow().isVisible()) {
|
||||||
return WindowState.Hidden;
|
windowState = WindowState.Hidden;
|
||||||
} else if (remote.getCurrentWindow().isMinimized()) {
|
} else if (remote.getCurrentWindow().isMinimized()) {
|
||||||
return WindowState.Minimized;
|
windowState = WindowState.Minimized;
|
||||||
} else if (remote.getCurrentWindow().isNormal()) {
|
} else if (remote.getCurrentWindow().isNormal()) {
|
||||||
return WindowState.Normal;
|
windowState = WindowState.Normal;
|
||||||
} else if (remote.getCurrentWindow().isMaximized()) {
|
} else if (remote.getCurrentWindow().isMaximized()) {
|
||||||
return WindowState.Maximized;
|
windowState = WindowState.Maximized;
|
||||||
} else if (remote.getCurrentWindow().isFullScreen()) {
|
} else if (remote.getCurrentWindow().isFullScreen()) {
|
||||||
return WindowState.FullScreen;
|
windowState = WindowState.FullScreen;
|
||||||
} else {
|
|
||||||
return WindowState.Normal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
windowState,
|
||||||
|
windowFocusState: this.windowFocusState
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
appExit(): void {
|
appExit(): void {
|
||||||
|
@ -532,5 +546,17 @@ 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;
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,8 @@ export enum ProcessChannel {
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum WindowStateChannel {
|
export enum WindowStateChannel {
|
||||||
Changed = 'UCAP::windowState::windowStateChanged'
|
Changed = 'UCAP::windowState::windowStateChanged',
|
||||||
|
FocuseChanged = 'UCAP::windowState::windowFocusStateChanged'
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum IdleStateChannel {
|
export enum IdleStateChannel {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { TranslateLoader } from '@ngx-translate/core';
|
||||||
import { StatusCode } from '@ucap-webmessenger/core';
|
import { StatusCode } from '@ucap-webmessenger/core';
|
||||||
import { UpdateInfo, UpdateCheckConfig } from '../models/update-info';
|
import { UpdateInfo, UpdateCheckConfig } from '../models/update-info';
|
||||||
import { NativeType } from '../types/native.type';
|
import { NativeType } from '../types/native.type';
|
||||||
|
import { ElectronBrowserWindowChannel } from '@ucap-webmessenger/electron-core';
|
||||||
|
|
||||||
export type NativePathName =
|
export type NativePathName =
|
||||||
| 'home'
|
| 'home'
|
||||||
|
@ -73,7 +74,12 @@ export abstract class NativeService {
|
||||||
abstract windowClose(): void;
|
abstract windowClose(): void;
|
||||||
abstract windowMinimize(): void;
|
abstract windowMinimize(): void;
|
||||||
abstract windowMaximize(): void;
|
abstract windowMaximize(): void;
|
||||||
abstract getWindowState(): WindowState;
|
abstract getWindowState(): {
|
||||||
|
windowState: WindowState;
|
||||||
|
windowFocusState:
|
||||||
|
| ElectronBrowserWindowChannel.Focus
|
||||||
|
| ElectronBrowserWindowChannel.Blur;
|
||||||
|
};
|
||||||
abstract zoomTo(factor: number): Promise<number>;
|
abstract zoomTo(factor: number): Promise<number>;
|
||||||
abstract appExit(): void;
|
abstract appExit(): void;
|
||||||
abstract appLogging(error: any): void;
|
abstract appLogging(error: any): void;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user