기능추가 :: 그룹 삭제
This commit is contained in:
parent
925c63f37d
commit
44bf93c54b
|
@ -11,7 +11,13 @@ import { map, tap } from 'rxjs/operators';
|
||||||
|
|
||||||
import { Store, select } from '@ngrx/store';
|
import { Store, select } from '@ngrx/store';
|
||||||
|
|
||||||
import { ucapAnimations, DialogService } from '@ucap-webmessenger/ui';
|
import {
|
||||||
|
ucapAnimations,
|
||||||
|
DialogService,
|
||||||
|
ConfirmDialogData,
|
||||||
|
ConfirmDialogComponent,
|
||||||
|
ConfirmDialogResult
|
||||||
|
} from '@ucap-webmessenger/ui';
|
||||||
import { UserInfo, GroupDetailData } from '@ucap-webmessenger/protocol-sync';
|
import { UserInfo, GroupDetailData } from '@ucap-webmessenger/protocol-sync';
|
||||||
|
|
||||||
import * as AppStore from '@app/store';
|
import * as AppStore from '@app/store';
|
||||||
|
@ -337,31 +343,21 @@ export class GroupComponent implements OnInit, OnDestroy {
|
||||||
case 'DELETE':
|
case 'DELETE':
|
||||||
{
|
{
|
||||||
const result = await this.dialogService.open<
|
const result = await this.dialogService.open<
|
||||||
DeleteGroupDialogComponent,
|
ConfirmDialogComponent,
|
||||||
DeleteGroupDialogData,
|
ConfirmDialogData,
|
||||||
DeleteGroupDialogResult
|
ConfirmDialogResult
|
||||||
>(DeleteGroupDialogComponent, {
|
>(ConfirmDialogComponent, {
|
||||||
width: '220px',
|
width: '220px',
|
||||||
data: {
|
data: {
|
||||||
title: 'Logout',
|
title: 'Delete group',
|
||||||
message: 'Logout ?'
|
html: `그룹(${group.name})을 삭제하시겠습니까?<br/>그룹 멤버는 해당 그룹에서만 삭제됩니다.`
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'EDIT_MEMBER':
|
|
||||||
{
|
|
||||||
const result = await this.dialogService.open<
|
|
||||||
EditGroupMemberDialogComponent,
|
|
||||||
EditGroupMemberDialogData,
|
|
||||||
EditGroupMemberDialogResult
|
|
||||||
>(EditGroupMemberDialogComponent, {
|
|
||||||
width: '220px',
|
|
||||||
data: {
|
|
||||||
title: 'Logout',
|
|
||||||
message: 'Logout ?'
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!!result && !!result.choice && result.choice) {
|
||||||
|
this.logger.debug('delete group', group);
|
||||||
|
this.store.dispatch(SyncStore.delGroup({ group }));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -17,7 +17,9 @@ import { Info } from '@ucap-webmessenger/protocol-event';
|
||||||
import {
|
import {
|
||||||
AddResponse as GroupAddResponse,
|
AddResponse as GroupAddResponse,
|
||||||
UpdateRequest as GroupUpdateRequest,
|
UpdateRequest as GroupUpdateRequest,
|
||||||
UpdateResponse as GroupUpdateResponse
|
UpdateResponse as GroupUpdateResponse,
|
||||||
|
DelRequest as GroupDelRequest,
|
||||||
|
DelResponse as GroupDelResponse
|
||||||
} from '@ucap-webmessenger/protocol-group';
|
} from '@ucap-webmessenger/protocol-group';
|
||||||
import {
|
import {
|
||||||
AddRequest as BuddyAddRequest,
|
AddRequest as BuddyAddRequest,
|
||||||
|
@ -115,24 +117,6 @@ export const updateUnreadCount = createAction(
|
||||||
}>()
|
}>()
|
||||||
);
|
);
|
||||||
|
|
||||||
/** 새그룹(Only Group) 추가 */
|
|
||||||
export const createGroup = createAction(
|
|
||||||
'[Messenger::Sync] Group Create',
|
|
||||||
props<{
|
|
||||||
groupName: string;
|
|
||||||
}>()
|
|
||||||
);
|
|
||||||
|
|
||||||
export const createGroupSuccess = createAction(
|
|
||||||
'[Messenger::Sync] Group Create Success',
|
|
||||||
props<GroupAddResponse>()
|
|
||||||
);
|
|
||||||
|
|
||||||
export const createGroupFailure = createAction(
|
|
||||||
'[Messenger::Sync] Group Create Failure',
|
|
||||||
props<{ error: any }>()
|
|
||||||
);
|
|
||||||
|
|
||||||
/** 새그룹 추가 & 그룹원 추가 */
|
/** 새그룹 추가 & 그룹원 추가 */
|
||||||
export const createGroupAndBuddy = createAction(
|
export const createGroupAndBuddy = createAction(
|
||||||
'[Messenger::Sync] Group & Buddy Create',
|
'[Messenger::Sync] Group & Buddy Create',
|
||||||
|
@ -206,18 +190,46 @@ export const updateBuddyFailure = createAction(
|
||||||
props<{ error: any }>()
|
props<{ error: any }>()
|
||||||
);
|
);
|
||||||
|
|
||||||
/** 그룹원 업데이트 */
|
/** 새그룹 추가 */
|
||||||
|
export const createGroup = createAction(
|
||||||
|
'[Messenger::Sync] Group Create',
|
||||||
|
props<{
|
||||||
|
groupName: string;
|
||||||
|
}>()
|
||||||
|
);
|
||||||
|
export const createGroupSuccess = createAction(
|
||||||
|
'[Messenger::Sync] Group Create Success',
|
||||||
|
props<GroupAddResponse>()
|
||||||
|
);
|
||||||
|
export const createGroupFailure = createAction(
|
||||||
|
'[Messenger::Sync] Group Create Failure',
|
||||||
|
props<{ error: any }>()
|
||||||
|
);
|
||||||
|
/** 그룹 업데이트 */
|
||||||
export const updateGroup = createAction(
|
export const updateGroup = createAction(
|
||||||
'[Messenger::Sync] Group Update',
|
'[Messenger::Sync] Group Update',
|
||||||
props<GroupUpdateRequest>()
|
props<GroupUpdateRequest>()
|
||||||
);
|
);
|
||||||
|
|
||||||
export const updateGroupSuccess = createAction(
|
export const updateGroupSuccess = createAction(
|
||||||
'[Messenger::Sync] Group Update Success',
|
'[Messenger::Sync] Group Update Success',
|
||||||
props<GroupUpdateResponse>()
|
props<GroupUpdateResponse>()
|
||||||
);
|
);
|
||||||
|
|
||||||
export const updateGroupFailure = createAction(
|
export const updateGroupFailure = createAction(
|
||||||
'[Messenger::Sync] Group Update Failure',
|
'[Messenger::Sync] Group Update Failure',
|
||||||
props<{ error: any }>()
|
props<{ error: any }>()
|
||||||
);
|
);
|
||||||
|
/** 그룹 삭제 */
|
||||||
|
export const delGroup = createAction(
|
||||||
|
'[Messenger::Sync] Group Del',
|
||||||
|
props<{
|
||||||
|
group: GroupDetailData;
|
||||||
|
}>()
|
||||||
|
);
|
||||||
|
export const delGroupSuccess = createAction(
|
||||||
|
'[Messenger::Sync] Group Del Success',
|
||||||
|
props<GroupDelResponse>()
|
||||||
|
);
|
||||||
|
export const delGroupFailure = createAction(
|
||||||
|
'[Messenger::Sync] Group Del Failure',
|
||||||
|
props<{ error: any }>()
|
||||||
|
);
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { GroupProtocolService } from './../../../../../../ucap-webmessenger-protocol-group/src/lib/services/group-protocol.service';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { Actions, ofType, createEffect } from '@ngrx/effects';
|
import { Actions, ofType, createEffect } from '@ngrx/effects';
|
||||||
|
@ -42,7 +43,10 @@ import {
|
||||||
updateGroupFailure,
|
updateGroupFailure,
|
||||||
updateGroupMember,
|
updateGroupMember,
|
||||||
updateBuddy,
|
updateBuddy,
|
||||||
delBuddySuccess
|
delBuddySuccess,
|
||||||
|
delGroup,
|
||||||
|
delGroupFailure,
|
||||||
|
delGroupSuccess
|
||||||
} from './actions';
|
} from './actions';
|
||||||
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
||||||
import { LoginInfo, KEY_LOGIN_INFO } from '@app/types';
|
import { LoginInfo, KEY_LOGIN_INFO } from '@app/types';
|
||||||
|
@ -81,9 +85,9 @@ import {
|
||||||
} from '@ucap-webmessenger/protocol-room';
|
} from '@ucap-webmessenger/protocol-room';
|
||||||
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
|
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
|
||||||
import {
|
import {
|
||||||
GroupProtocolService,
|
|
||||||
AddResponse as GroupAddResponse,
|
AddResponse as GroupAddResponse,
|
||||||
UpdateResponse as GroupUpdateResponse
|
UpdateResponse as GroupUpdateResponse,
|
||||||
|
DelResponse as GroupDelResponse
|
||||||
} from '@ucap-webmessenger/protocol-group';
|
} from '@ucap-webmessenger/protocol-group';
|
||||||
import {
|
import {
|
||||||
BuddyProtocolService,
|
BuddyProtocolService,
|
||||||
|
@ -462,11 +466,9 @@ export class Effects {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (addBuddyList.length > 0) {
|
if (addBuddyList.length > 0) {
|
||||||
this.logger.debug('addBuddyList : ', addBuddyList);
|
|
||||||
this.store.dispatch(addBuddy({ userSeqs: addBuddyList }));
|
this.store.dispatch(addBuddy({ userSeqs: addBuddyList }));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.debug('group buddy : ', action.trgtUserSeq);
|
|
||||||
this.store.dispatch(
|
this.store.dispatch(
|
||||||
updateGroup({
|
updateGroup({
|
||||||
// 0: 동료그룹SEQ(n)
|
// 0: 동료그룹SEQ(n)
|
||||||
|
@ -534,12 +536,10 @@ export class Effects {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (addBuddyList.length > 0) {
|
if (addBuddyList.length > 0) {
|
||||||
this.logger.debug('addBuddyList : ', addBuddyList);
|
|
||||||
this.store.dispatch(addBuddy({ userSeqs: addBuddyList }));
|
this.store.dispatch(addBuddy({ userSeqs: addBuddyList }));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (delBuddyInGroup.length > 0) {
|
if (delBuddyInGroup.length > 0) {
|
||||||
this.logger.debug('delBuddyInGroup', delBuddyInGroup);
|
|
||||||
// 즐겨찾기 해제.
|
// 즐겨찾기 해제.
|
||||||
delBuddyInGroup.forEach(buddySeq => {
|
delBuddyInGroup.forEach(buddySeq => {
|
||||||
this.buddyProtocolService
|
this.buddyProtocolService
|
||||||
|
@ -568,6 +568,75 @@ export class Effects {
|
||||||
{ dispatch: false }
|
{ dispatch: false }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
delGroup$ = createEffect(
|
||||||
|
() => {
|
||||||
|
return this.actions$.pipe(
|
||||||
|
ofType(delGroup),
|
||||||
|
withLatestFrom(
|
||||||
|
this.store.pipe(
|
||||||
|
select(
|
||||||
|
(state: any) =>
|
||||||
|
state.messenger.sync.group2.entities as Dictionary<
|
||||||
|
GroupDetailData
|
||||||
|
>
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
map(([action, groupList]) => {
|
||||||
|
// Del Buddy
|
||||||
|
const trgtBuddys = action.group.userSeqs;
|
||||||
|
// tslint:disable-next-line: no-shadowed-variable
|
||||||
|
const delBuddyList = trgtBuddys.filter(delBuddy => {
|
||||||
|
let exist = false;
|
||||||
|
// tslint:disable-next-line: forin
|
||||||
|
for (const key in groupList) {
|
||||||
|
const group: GroupDetailData = groupList[key];
|
||||||
|
if (
|
||||||
|
group.seq !== action.group.seq &&
|
||||||
|
group.userSeqs.filter(v => v === delBuddy).length > 0
|
||||||
|
) {
|
||||||
|
exist = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return !exist;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (delBuddyList.length > 0) {
|
||||||
|
this.logger.debug('Del Buddy', delBuddyList);
|
||||||
|
// 즐겨찾기 해제.
|
||||||
|
delBuddyList.forEach(buddySeq => {
|
||||||
|
this.buddyProtocolService
|
||||||
|
.update({
|
||||||
|
seq: buddySeq,
|
||||||
|
isFavorit: false
|
||||||
|
})
|
||||||
|
.pipe(catchError(error => of(delBuddyFailure({ error }))));
|
||||||
|
});
|
||||||
|
|
||||||
|
// 동료 삭제
|
||||||
|
this.store.dispatch(delBuddy({ userSeqs: delBuddyList }));
|
||||||
|
}
|
||||||
|
|
||||||
|
return action.group;
|
||||||
|
}),
|
||||||
|
tap(group => {
|
||||||
|
this.groupProtocolService
|
||||||
|
.del({
|
||||||
|
groupSeq: group.seq
|
||||||
|
})
|
||||||
|
.pipe(
|
||||||
|
map((res: GroupDelResponse) => {
|
||||||
|
return delGroupSuccess(res);
|
||||||
|
}),
|
||||||
|
catchError(error => of(delGroupFailure({ error })))
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{ dispatch: false }
|
||||||
|
);
|
||||||
|
|
||||||
addBuddy$ = createEffect(() =>
|
addBuddy$ = createEffect(() =>
|
||||||
this.actions$.pipe(
|
this.actions$.pipe(
|
||||||
ofType(addBuddy),
|
ofType(addBuddy),
|
||||||
|
|
|
@ -16,7 +16,8 @@ import {
|
||||||
updateUnreadCount,
|
updateUnreadCount,
|
||||||
createGroupSuccess,
|
createGroupSuccess,
|
||||||
addBuddySuccess,
|
addBuddySuccess,
|
||||||
delBuddySuccess
|
delBuddySuccess,
|
||||||
|
delGroupSuccess
|
||||||
} from './actions';
|
} from './actions';
|
||||||
import {
|
import {
|
||||||
RoomUserDetailData,
|
RoomUserDetailData,
|
||||||
|
@ -204,6 +205,15 @@ export const reducer = createReducer(
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
|
/** 새 그룹 삭제 */
|
||||||
|
on(delGroupSuccess, (state, action) => {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
group2: adapterGroup2.removeOne(action.groupSeq, {
|
||||||
|
...state.group2
|
||||||
|
})
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
|
||||||
on(delBuddySuccess, (state, action) => {
|
on(delBuddySuccess, (state, action) => {
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user