diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html index bf47f966..46d87577 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html @@ -135,12 +135,7 @@ " class="member-state-msg text-warn-color" > - - {{ 'chat.existOfflineUser' | translate }} - - - {{ 'chat.existOfflineUsers' | translate }} - + {{ getOfflineString() }}
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 47561ae1..369262fb 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 @@ -354,18 +354,33 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { .pipe( tap(([userInfoList, presences]) => { if (!!userInfoList && userInfoList.length > 0) { - userInfoList.forEach(userInfo => { - const presence = presences[userInfo.seq]; + userInfoList + .filter( + info => + info.seq !== this.loginResSubject.value.userSeq && + !!info.isJoinRoom + ) + .forEach(userInfo => { + const presence = presences[userInfo.seq]; + const existIndex = !!this.offLineUsers + ? this.offLineUsers.findIndex(e => e.seq === userInfo.seq) + : -1; - if ( - !!presence && - presence.pcStatus === PresenceStatusCode.OnLine - ) { - } else { - this.offLineUsers.push(userInfo); - } - }); + if ( + !!presence && + presence.pcStatus === PresenceStatusCode.OnLine + ) { + if (existIndex > -1) { + this.offLineUsers.splice(existIndex, 1); + } + } else { + if (existIndex === -1) { + this.offLineUsers.push(userInfo); + } + } + }); } + console.log(this.offLineUsers); }) ) .subscribe(); @@ -619,6 +634,31 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { } } + getOfflineString() { + let offlineStr = ''; + if (!!this.offLineUsers && this.offLineUsers.length > 0) { + if ( + !!this.roomInfoSubject.value && + this.roomInfoSubject.value.roomType === RoomType.Single + ) { + const name = new UiTranslatePipe( + this.uiTranslateService, + this.changeDetectorRef + ).transform(this.offLineUsers[0], 'name'); + + offlineStr = this.translateService.instant('chat.existOfflineUser', { + offlineUser: name + }); + } else if ( + !!this.roomInfoSubject.value && + this.roomInfoSubject.value.roomType === RoomType.Multi + ) { + offlineStr = this.translateService.instant('chat.existOfflineUsers'); + } + } + return offlineStr; + } + onClickSendClickToCall(type: string) { if (type === 'LINE') { this.sendCall.emit(this._roomUserInfos[0].lineNumber); diff --git a/projects/ucap-webmessenger-app/src/assets/i18n/en.json b/projects/ucap-webmessenger-app/src/assets/i18n/en.json index bccd8684..9a3a1546 100644 --- a/projects/ucap-webmessenger-app/src/assets/i18n/en.json +++ b/projects/ucap-webmessenger-app/src/assets/i18n/en.json @@ -238,8 +238,8 @@ "btnSticker": "Sticker", "btnTranslate": "Translate", "noRoomUser": "No chat users", - "existOfflineUser": "offline", - "existOfflineUsers": "Some offline", + "existOfflineUser": "{{offlineUser}} may not respond because it is [offline].", + "existOfflineUsers": "Some chat partners may not respond because they are not online.", "event": { "inviteToRoomWith": "{{owner}} invited {{inviter}}.", "exitFromRoomWith": "{{exitor}} has left.", diff --git a/projects/ucap-webmessenger-app/src/assets/i18n/ko.json b/projects/ucap-webmessenger-app/src/assets/i18n/ko.json index c9afcd7e..5480cc4c 100644 --- a/projects/ucap-webmessenger-app/src/assets/i18n/ko.json +++ b/projects/ucap-webmessenger-app/src/assets/i18n/ko.json @@ -238,8 +238,8 @@ "btnSticker": "스티커", "btnTranslate": "번역", "noRoomUser": "대화상대 없음", - "existOfflineUser": "오프라인 입니다.", - "existOfflineUsers": "일부 인원이 오프라인 입니다.", + "existOfflineUser": "{{offlineUser}}님이 [오프라인]이므로 응답하지 않을 수도 있습니다.", + "existOfflineUsers": "일부 대화상대는 온라인 상태가 아니어서 응답하지 않을 수도 있습니다.", "event": { "inviteToRoomWith": "{{owner}}이 {{inviter}}을 초대했습니다.", "exitFromRoomWith": "{{exitor}}님이 퇴장하셨습니다.",