노티 팝업에 사용자 정보 표시하도록 수정.
1. searching in buddy 2. searching in current opened room 3. searching for protocols
This commit is contained in:
parent
ca9e8942e7
commit
a725d91326
|
@ -1,6 +1,13 @@
|
|||
import { Injectable, Inject } from '@angular/core';
|
||||
|
||||
import { tap, withLatestFrom } from 'rxjs/operators';
|
||||
import {
|
||||
tap,
|
||||
withLatestFrom,
|
||||
take,
|
||||
map,
|
||||
catchError,
|
||||
finalize
|
||||
} from 'rxjs/operators';
|
||||
|
||||
import { Store, select } from '@ngrx/store';
|
||||
|
||||
|
@ -116,7 +123,12 @@ import { environment } from '../../environments/environment';
|
|||
import { NotificationMethod, LocaleCode } from '@ucap-webmessenger/core';
|
||||
import { Dictionary } from '@ngrx/entity';
|
||||
import { MessageType } from '@ucap-webmessenger/api-message';
|
||||
import { LogoutInfo, KEY_LOGOUT_INFO, KEY_VER_INFO } from '@app/types';
|
||||
import {
|
||||
LogoutInfo,
|
||||
KEY_LOGOUT_INFO,
|
||||
KEY_VER_INFO,
|
||||
KEY_LOGIN_RES_INFO
|
||||
} from '@app/types';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { deleteMessageSuccess } from '@app/store/messenger/message';
|
||||
import { ServerErrorCode } from '@ucap-webmessenger/protocol';
|
||||
|
@ -138,6 +150,8 @@ import { UserInfo, RoomUserData } from '@ucap-webmessenger/protocol-sync';
|
|||
import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
|
||||
import { QueryProtocolService } from '@ucap-webmessenger/protocol-query';
|
||||
import { UserInfoListState } from '@app/store/messenger/room';
|
||||
import { DaesangProtocolService } from '@ucap-webmessenger/daesang';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
@Injectable()
|
||||
export class AppNotificationService {
|
||||
|
@ -149,6 +163,7 @@ export class AppNotificationService {
|
|||
private groupProtocolService: GroupProtocolService,
|
||||
private buddyProtocolService: BuddyProtocolService,
|
||||
private queryProtocolService: QueryProtocolService,
|
||||
private daesangProtocolService: DaesangProtocolService,
|
||||
private statusProtocolService: StatusProtocolService,
|
||||
private translateService: TranslateService,
|
||||
private ucapTranslateService: UcapTranslateService,
|
||||
|
@ -233,25 +248,10 @@ export class AppNotificationService {
|
|||
(state: any) =>
|
||||
state.messenger.sync.buddy2.entities as Dictionary<UserInfo>
|
||||
)
|
||||
),
|
||||
this.store.pipe(
|
||||
select(
|
||||
(state: any) =>
|
||||
state.messenger.sync.roomUserShort.entities as Dictionary<
|
||||
RoomUserData
|
||||
>
|
||||
)
|
||||
)
|
||||
),
|
||||
tap(
|
||||
([
|
||||
notiOrRes,
|
||||
curRoomInfo,
|
||||
curRoomUserInfo,
|
||||
roomList,
|
||||
buddyList,
|
||||
roomUserShorts
|
||||
]) => {
|
||||
([notiOrRes, curRoomInfo, curRoomUserInfo, roomList, buddyList]) => {
|
||||
switch (notiOrRes.SSVC_TYPE) {
|
||||
case SSVC_TYPE_EVENT_SEND_RES:
|
||||
case SSVC_TYPE_EVENT_SEND_NOTI:
|
||||
|
@ -356,32 +356,70 @@ export class AppNotificationService {
|
|||
senderInfo = curRoomUserInfo[noti.SENDER_SEQ];
|
||||
}
|
||||
|
||||
// STEP 3 >> In All Room Users.
|
||||
// STEP 3 >> user protocol
|
||||
if (!senderInfo) {
|
||||
for (const key in roomUserShorts) {
|
||||
if (key === undefined) {
|
||||
continue;
|
||||
}
|
||||
const loginRes = this.sessionStorageService.get<
|
||||
LoginResponse
|
||||
>(KEY_LOGIN_RES_INFO);
|
||||
|
||||
if (roomUserShorts.hasOwnProperty(key)) {
|
||||
const element = roomUserShorts[key];
|
||||
const filteredUserInfos = element.userInfos.filter(
|
||||
info => info.seq === noti.SENDER_SEQ
|
||||
);
|
||||
this.daesangProtocolService
|
||||
.dataUserDaesang({
|
||||
divCd: 'OPENNOTI',
|
||||
seq: noti.SENDER_SEQ,
|
||||
senderCompanyCode:
|
||||
loginRes.userInfo.companyCode,
|
||||
senderEmployeeType:
|
||||
loginRes.userInfo.employeeType
|
||||
})
|
||||
.pipe(
|
||||
take(1),
|
||||
map(res => {
|
||||
if (!!res && !!res.userInfo) {
|
||||
senderInfo = res.userInfo;
|
||||
let name = senderInfo.name;
|
||||
let grade = senderInfo.grade;
|
||||
|
||||
if (
|
||||
!!filteredUserInfos &&
|
||||
filteredUserInfos.length > 0
|
||||
switch (
|
||||
this.ucapTranslateService.currentLang.toUpperCase()
|
||||
) {
|
||||
senderInfo = filteredUserInfos[0];
|
||||
case LocaleCode.English:
|
||||
name = senderInfo.nameEn;
|
||||
grade = senderInfo.gradeEn;
|
||||
break;
|
||||
case LocaleCode.Chinese:
|
||||
name = senderInfo.nameCn;
|
||||
grade = senderInfo.gradeCn;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
notiReq.title = this.translateService.instant(
|
||||
'notification.titleChatEventArrivedByUser',
|
||||
{
|
||||
userInfo: !!grade
|
||||
? `${name} ${grade}`
|
||||
: name
|
||||
}
|
||||
);
|
||||
|
||||
// Image set.
|
||||
if (!!senderInfo.profileImageFile) {
|
||||
const sessionVerinfo = this.sessionStorageService.get<
|
||||
VersionInfo2Response
|
||||
>(KEY_VER_INFO);
|
||||
notiReq.image = `${sessionVerinfo.profileRoot}${senderInfo.profileImageFile}`;
|
||||
}
|
||||
}
|
||||
}),
|
||||
catchError(error => {
|
||||
return of();
|
||||
}),
|
||||
finalize(() => {
|
||||
this.nativeService.notify(notiReq);
|
||||
})
|
||||
)
|
||||
.subscribe();
|
||||
} else {
|
||||
// Sender Info setting.
|
||||
if (!!senderInfo) {
|
||||
// name set
|
||||
let name = senderInfo.name;
|
||||
let grade = senderInfo.grade;
|
||||
|
@ -413,7 +451,6 @@ export class AppNotificationService {
|
|||
>(KEY_VER_INFO);
|
||||
notiReq.image = `${sessionVerinfo.profileRoot}${senderInfo.profileImageFile}`;
|
||||
}
|
||||
}
|
||||
|
||||
// express noti popup
|
||||
this.nativeService.notify(notiReq);
|
||||
|
@ -423,6 +460,7 @@ export class AppNotificationService {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SSVC_TYPE_EVENT_READ_RES:
|
||||
case SSVC_TYPE_EVENT_READ_NOTI:
|
||||
|
|
Loading…
Reference in New Issue
Block a user