ucap-doc/documents/업무/4월/3째주/sync-effect.ts

129 lines
3.7 KiB
TypeScript
Raw Normal View History

2020-04-13 03:57:55 +00:00
updateProfileImageNoti$ = createEffect(
() =>
this.actions$.pipe(
ofType(updateProfileImageNoti),
withLatestFrom(
this.store.pipe(
select(
(state: any) =>
state.messenger.sync.room.entities as Dictionary<RoomInfo>
)
),
this.store.pipe(
select(
(state: any) =>
state.messenger.sync.roomUserShort.entities as Dictionary<
RoomUserData
>
)
)
// this.store.pipe(
// select(
// (state: any) => state.messenger.sync.buddy2.syncDate as string
// )
// ),
// this.store.pipe(
// select(
// (state: any) => state.messenger.sync.group2.syncDate as string
// )
// ),
// this.store.pipe(
// select((state: any) => state.messenger.sync.room.syncDate as string)
// )
// tap(async ([action, buddy2SyncDate, group2SyncDate, roomSyncDate]) => {
),
tap(async ([action, roomInfos, roomUserShorts]) => {
const userNoti = action.noti as UserNotification;
// const loginInfo = this.sessionStorageService.get<LoginInfo>(
// KEY_LOGIN_INFO
// );
// this.store.dispatch(buddy2({ syncDate: buddy2SyncDate }));
// this.store.dispatch(group2({ syncDate: group2SyncDate }));
// this.store.dispatch(
// room({
// syncDate: roomSyncDate,
// localeCode: loginInfo.localeCode
// })
// );
this.store.dispatch(
updateBuddyProfile({
noti: userNoti
})
);
for (const key in roomUserShorts) {
if (key === undefined) {
continue;
}
if (roomUserShorts.hasOwnProperty(key)) {
const element = roomUserShorts[key];
const tmpRoomInfo = roomInfos[key];
if (
tmpRoomInfo.roomType === RoomType.Single ||
tmpRoomInfo.roomType === RoomType.Allim_Lbot
) {
const findUser = element.userInfos.filter(
(u) => u.seq === userNoti.SENDER_SEQ
)[0];
if (!!findUser && !!findUser.seq) {
const tmpUserInfos: UserInfoShort[] = [];
element.userInfos.map((u) => {
let user: UserInfoShort;
if (!!u && u.seq === userNoti.SENDER_SEQ) {
user = {
...u,
profileImageFile: userNoti.info
};
} else {
user = u;
}
tmpUserInfos.push(user);
});
const roomData = {
roomSeq: roomInfos[key].roomSeq,
userInfos: tmpUserInfos
} as RoomUserData;
this.store.dispatch(
updateRoomUserShortProfile({
roomData,
noti: userNoti
})
);
break;
}
}
}
}
})
),
{ dispatch: false }
);
// updateProfileImageNoti$ = createEffect(() =>
// this.actions$.pipe(
// ofType(updateProfileImageNoti),
// withLatestFrom(
// this.store.pipe(
// select(
// (state: any) =>
// state.messenger.sync.roomUserShort.entities as Dictionary<
// RoomUserData
// >
// )
// )
// ),
// tap(async ([action, roomUserShorts]) => {
// const userNoti = action.noti as UserNotification;
// })
// )
// );