From ca9e8942e77ff615a59bbfb7446b20fa6c312d5e Mon Sep 17 00:00:00 2001 From: leejinho Date: Mon, 30 Mar 2020 15:28:20 +0900 Subject: [PATCH] =?UTF-8?q?=EB=8C=80=ED=99=94=20=EB=B1=83=EC=A7=80?= =?UTF-8?q?=EA=B0=80=20=EB=82=A8=EC=95=84=20=EC=9E=88=EC=9D=84=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=20=EA=B3=84=EC=86=8D=20taskbar=20=EC=97=90=20blink=20?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/app/AppWindow.ts | 2 +- .../ucap-webmessenger-electron/src/index.ts | 34 ++++++++++++++++--- .../components/left-nav.component.ts | 29 ++++++++++++++-- .../components/messages.component.ts | 1 - .../lib/services/browser-native.service.ts | 2 ++ .../lib/services/electron-native.service.ts | 6 ++++ .../src/lib/types/channel.type.ts | 4 ++- .../src/lib/services/native.service.ts | 2 ++ 8 files changed, 70 insertions(+), 10 deletions(-) diff --git a/electron-projects/ucap-webmessenger-electron/src/app/AppWindow.ts b/electron-projects/ucap-webmessenger-electron/src/app/AppWindow.ts index 134bf0fa..51c1d811 100644 --- a/electron-projects/ucap-webmessenger-electron/src/app/AppWindow.ts +++ b/electron-projects/ucap-webmessenger-electron/src/app/AppWindow.ts @@ -89,7 +89,7 @@ export class AppWindow { // windows Focus or Blur state detacted. this.window.on(ElectronBrowserWindowChannel.Focus, () => { if (__WIN32__) { - this.window.flashFrame(false); + // this.window.flashFrame(false); } this.window.webContents.send( diff --git a/electron-projects/ucap-webmessenger-electron/src/index.ts b/electron-projects/ucap-webmessenger-electron/src/index.ts index ad714b2f..95f59b14 100644 --- a/electron-projects/ucap-webmessenger-electron/src/index.ts +++ b/electron-projects/ucap-webmessenger-electron/src/index.ts @@ -8,7 +8,8 @@ import { dialog, BrowserWindow, clipboard, - crashReporter + crashReporter, + nativeImage } from 'electron'; import path from 'path'; import fse from 'fs-extra'; @@ -35,7 +36,8 @@ import { MessageChannel, AppChannel, ClipboardChannel, - ExternalChannel + ExternalChannel, + WindowStateChannel } from '@ucap-webmessenger/native-electron'; import { ElectronNotificationService } from '@ucap-webmessenger/electron-notification'; import { ElectronUpdateWindowService } from '@ucap-webmessenger/electron-update-window'; @@ -800,7 +802,7 @@ ipcMain.on( : '', displayTime: !!noti.displayTime ? noti.displayTime : undefined, onClick: e => { - appWindow.browserWindow.flashFrame(false); + // appWindow.browserWindow.flashFrame(false); if (noti.type === NotificationType.Event) { appWindow.browserWindow.webContents.send( ChatChannel.OpenRoom, @@ -820,13 +822,37 @@ ipcMain.on( if (!appWindow.isVisible()) { appWindow.browserWindow.minimize(); } - + // const img = nativeImage.createFromPath( + // path.join(__dirname, 'assets/notification/images/img_nophoto_50.png') + // ); + // console.log(img); + // appWindow.browserWindow.setOverlayIcon(img, 'discription'); + // setTimeout(() => { + // appWindow.browserWindow.setOverlayIcon(null, ''); + // }, 3000); appWindow.browserWindow.flashFrame(true); } ); ipcMain.on( NotificationChannel.CloseAllNotify, + (event: IpcMainEvent, ...args: any[]) => { + // appWindow.browserWindow.flashFrame(false); + } +); + +ipcMain.on( + WindowStateChannel.OnFlashFrame, + (event: IpcMainEvent, ...args: any[]) => { + appWindow.browserWindow.flashFrame(false); + if (!appWindow.isVisible() && !appWindow.browserWindow.isMinimized()) { + appWindow.browserWindow.minimize(); + } + appWindow.browserWindow.flashFrame(true); + } +); +ipcMain.on( + WindowStateChannel.OffFlashFrame, (event: IpcMainEvent, ...args: any[]) => { appWindow.browserWindow.flashFrame(false); } diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-nav.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-nav.component.ts index 093061a9..fdac3f39 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-nav.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-nav.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, OnDestroy } from '@angular/core'; +import { Component, OnInit, OnDestroy, Inject } from '@angular/core'; import { NGXLogger } from 'ngx-logger'; import { ucapAnimations } from '@ucap-webmessenger/ui'; import { Observable } from 'rxjs'; @@ -9,6 +9,8 @@ import * as MessageStore from '@app/store/messenger/message'; import * as SettingsStore from '@app/store/messenger/settings'; import { MatTabChangeEvent } from '@angular/material/tabs'; import { MainMenu } from '@app/types'; +import { tap } from 'rxjs/operators'; +import { UCAP_NATIVE_SERVICE, NativeService } from '@ucap-webmessenger/native'; @Component({ selector: 'app-layout-messenger-left-nav', @@ -22,13 +24,34 @@ export class LeftNaviComponent implements OnInit, OnDestroy { badgeMessageInterval: any; MainMenu = MainMenu; + intervalFlashFrame: any; - constructor(private store: Store, private logger: NGXLogger) {} + constructor( + private store: Store, + @Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService, + private logger: NGXLogger + ) {} ngOnInit() { /** About Chat Badge */ this.badgeChatUnReadCount$ = this.store.pipe( - select(AppStore.MessengerSelector.SyncSelector.selectChatUnreadCount) + select(AppStore.MessengerSelector.SyncSelector.selectChatUnreadCount), + tap(count => { + // windows taskbar blinking unread count exist. + if (!!count && count > 0) { + if (!this.intervalFlashFrame) { + this.intervalFlashFrame = setInterval(() => { + this.nativeService.onFlashFlame(); + }, 1000); + } + } else { + this.nativeService.offFlashFlame(); + if (!!this.intervalFlashFrame) { + clearInterval(this.intervalFlashFrame); + this.intervalFlashFrame = undefined; + } + } + }) ); /** About Message Badge */ diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts index f360f569..b58b2b74 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts @@ -380,7 +380,6 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { } }); } - console.log(this.offLineUsers); }) ) .subscribe(); 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 dc284721..64ccb9c2 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 @@ -213,6 +213,8 @@ export class BrowserNativeService extends NativeService { }); } + onFlashFlame(): void {} + offFlashFlame(): void {} windowStateChanged(): Observable { return new Observable(subscriber => { try { 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 951fb55e..3ca355cf 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 @@ -352,6 +352,12 @@ export class ElectronNativeService implements NativeService { }); } + onFlashFlame(): void { + this.ipcRenderer.send(WindowStateChannel.OnFlashFrame); + } + offFlashFlame(): void { + this.ipcRenderer.send(WindowStateChannel.OffFlashFrame); + } windowStateChanged(): Observable { if (!this.windowStateChangedSubject) { this.windowStateChangedSubject = new Subject(); 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 772b89d7..00238e7b 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 @@ -47,7 +47,9 @@ export enum ProcessChannel { export enum WindowStateChannel { Changed = 'UCAP::windowState::windowStateChanged', - FocuseChanged = 'UCAP::windowState::windowFocusStateChanged' + FocuseChanged = 'UCAP::windowState::windowFocusStateChanged', + OnFlashFrame = 'UCAP::windowState::OnFlashFrame', + OffFlashFrame = 'UCAP::windowState::OffFlashFrame' } export enum IdleStateChannel { 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 e052a398..76b7aed8 100644 --- a/projects/ucap-webmessenger-native/src/lib/services/native.service.ts +++ b/projects/ucap-webmessenger-native/src/lib/services/native.service.ts @@ -70,6 +70,8 @@ export abstract class NativeService { abstract executeProcess(executableName: string): Promise; + abstract onFlashFlame(): void; + abstract offFlashFlame(): void; abstract windowStateChanged(): Observable; abstract windowClose(): void; abstract windowMinimize(): void;