From 3f61451be680bcbb91c6d0ad9ee5577069e25ce5 Mon Sep 17 00:00:00 2001 From: leejinho Date: Tue, 4 Feb 2020 17:02:27 +0900 Subject: [PATCH] =?UTF-8?q?=EB=8C=80=ED=99=94=ED=83=80=EC=9E=85=EC=97=90?= =?UTF-8?q?=20=EB=94=B0=EB=9D=BC=20=EB=85=B8=ED=8B=B0,=20snackbar=20?= =?UTF-8?q?=EC=B6=9C=EB=A0=A5=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8F=84?= =?UTF-8?q?=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 case EventType.Join: case EventType.Exit: case EventType.ForcedExit: case EventType.RenameRoom: case EventType.NotificationForTimerRoom: case EventType.GuideForRoomTimerChanged: --- .../components/messages.component.ts | 46 ++++++++------- .../src/app/services/notification.service.ts | 56 ++++++++++--------- 2 files changed, 56 insertions(+), 46 deletions(-) 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 20fc8326..62a655ef 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 @@ -968,32 +968,36 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { onExistNewMessage(info: Info) { let message = ''; - const senderUser = this.userInfoListSubject.value.filter( - user => user.seq === info.senderSeq - ); - if (!!senderUser && senderUser.length > 0) { - message += `${senderUser[0].name} : `; - } - message += StringUtil.convertFinalEventMessage( + const contents = StringUtil.convertFinalEventMessage( info.type, info.sentMessageJson || info.sentMessage ); - this.snackBarPreviewEvent = this.snackBarService.open( - message, - this.translateService.instant('common.messages.confirm'), - { - // duration: 3000, - verticalPosition: 'bottom', - horizontalPosition: 'center', - panelClass: ['chat-snackbar-class'] + if (!!contents) { + const senderUser = this.userInfoListSubject.value.filter( + user => user.seq === info.senderSeq + ); + if (!!senderUser && senderUser.length > 0) { + message += `${senderUser[0].name} : `; } - ); - this.snackBarPreviewEvent.onAction().subscribe(() => { - this.chatMessages.initEventMore(); - this.chatMessages.scrollToBottom(); - this.snackBarPreviewEvent.dismiss(); - }); + message += contents; + + this.snackBarPreviewEvent = this.snackBarService.open( + message, + this.translateService.instant('common.messages.confirm'), + { + // duration: 3000, + verticalPosition: 'bottom', + horizontalPosition: 'center', + panelClass: ['chat-snackbar-class'] + } + ); + this.snackBarPreviewEvent.onAction().subscribe(() => { + this.chatMessages.initEventMore(); + this.chatMessages.scrollToBottom(); + this.snackBarPreviewEvent.dismiss(); + }); + } } saveFile( diff --git a/projects/ucap-webmessenger-app/src/app/services/notification.service.ts b/projects/ucap-webmessenger-app/src/app/services/notification.service.ts index a13b3352..24d23d61 100644 --- a/projects/ucap-webmessenger-app/src/app/services/notification.service.ts +++ b/projects/ucap-webmessenger-app/src/app/services/notification.service.ts @@ -24,7 +24,8 @@ import { SSVC_TYPE_EVENT_CANCEL_NOTI, SSVC_TYPE_EVENT_DEL_RES, SSVC_TYPE_EVENT_SEND_RES, - SSVC_TYPE_EVENT_READ_RES + SSVC_TYPE_EVENT_READ_RES, + EventType } from '@ucap-webmessenger/protocol-event'; import { InfoProtocolService, @@ -248,30 +249,35 @@ export class AppNotificationService { ); audio.play(); } else { - const notiReq: NotificationRequest = { - type: NotificationType.Event, - seq: noti.roomSeq, - title: this.translateService.instant( - 'notification.titleChatEventArrived' - ), - contents: StringUtil.convertFinalEventMessage( - noti.eventType, - noti.info.sentMessageJson - ), - image: '', - useSound: [ - NotificationMethod.Sound, - NotificationMethod.SoundAndAlert - ].some( - n => n === appUserInfo.settings.notification.method - ) - ? true - : false, - displayTime: - appUserInfo.settings.notification - .alertExposureTime * 1000 - }; - this.nativeService.notify(notiReq); + const contents = StringUtil.convertFinalEventMessage( + noti.eventType, + noti.info.sentMessageJson + ); + + if (!!contents) { + const notiReq: NotificationRequest = { + type: NotificationType.Event, + seq: noti.roomSeq, + title: this.translateService.instant( + 'notification.titleChatEventArrived' + ), + contents, + image: '', + useSound: [ + NotificationMethod.Sound, + NotificationMethod.SoundAndAlert + ].some( + n => + n === appUserInfo.settings.notification.method + ) + ? true + : false, + displayTime: + appUserInfo.settings.notification + .alertExposureTime * 1000 + }; + this.nativeService.notify(notiReq); + } } } }