기능추가 :: 그룹 삭제
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 { 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 * as AppStore from '@app/store';
|
||||
|
@ -337,31 +343,21 @@ export class GroupComponent implements OnInit, OnDestroy {
|
|||
case 'DELETE':
|
||||
{
|
||||
const result = await this.dialogService.open<
|
||||
DeleteGroupDialogComponent,
|
||||
DeleteGroupDialogData,
|
||||
DeleteGroupDialogResult
|
||||
>(DeleteGroupDialogComponent, {
|
||||
ConfirmDialogComponent,
|
||||
ConfirmDialogData,
|
||||
ConfirmDialogResult
|
||||
>(ConfirmDialogComponent, {
|
||||
width: '220px',
|
||||
data: {
|
||||
title: 'Logout',
|
||||
message: 'Logout ?'
|
||||
title: 'Delete group',
|
||||
html: `그룹(${group.name})을 삭제하시겠습니까?<br/>그룹 멤버는 해당 그룹에서만 삭제됩니다.`
|
||||
}
|
||||
});
|
||||
|
||||
if (!!result && !!result.choice && result.choice) {
|
||||
this.logger.debug('delete group', group);
|
||||
this.store.dispatch(SyncStore.delGroup({ group }));
|
||||
}
|
||||
break;
|
||||
case 'EDIT_MEMBER':
|
||||
{
|
||||
const result = await this.dialogService.open<
|
||||
EditGroupMemberDialogComponent,
|
||||
EditGroupMemberDialogData,
|
||||
EditGroupMemberDialogResult
|
||||
>(EditGroupMemberDialogComponent, {
|
||||
width: '220px',
|
||||
data: {
|
||||
title: 'Logout',
|
||||
message: 'Logout ?'
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -17,7 +17,9 @@ import { Info } from '@ucap-webmessenger/protocol-event';
|
|||
import {
|
||||
AddResponse as GroupAddResponse,
|
||||
UpdateRequest as GroupUpdateRequest,
|
||||
UpdateResponse as GroupUpdateResponse
|
||||
UpdateResponse as GroupUpdateResponse,
|
||||
DelRequest as GroupDelRequest,
|
||||
DelResponse as GroupDelResponse
|
||||
} from '@ucap-webmessenger/protocol-group';
|
||||
import {
|
||||
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(
|
||||
'[Messenger::Sync] Group & Buddy Create',
|
||||
|
@ -206,18 +190,46 @@ export const updateBuddyFailure = createAction(
|
|||
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(
|
||||
'[Messenger::Sync] Group Update',
|
||||
props<GroupUpdateRequest>()
|
||||
);
|
||||
|
||||
export const updateGroupSuccess = createAction(
|
||||
'[Messenger::Sync] Group Update Success',
|
||||
props<GroupUpdateResponse>()
|
||||
);
|
||||
|
||||
export const updateGroupFailure = createAction(
|
||||
'[Messenger::Sync] Group Update Failure',
|
||||
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 { Actions, ofType, createEffect } from '@ngrx/effects';
|
||||
|
@ -42,7 +43,10 @@ import {
|
|||
updateGroupFailure,
|
||||
updateGroupMember,
|
||||
updateBuddy,
|
||||
delBuddySuccess
|
||||
delBuddySuccess,
|
||||
delGroup,
|
||||
delGroupFailure,
|
||||
delGroupSuccess
|
||||
} from './actions';
|
||||
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
||||
import { LoginInfo, KEY_LOGIN_INFO } from '@app/types';
|
||||
|
@ -81,9 +85,9 @@ import {
|
|||
} from '@ucap-webmessenger/protocol-room';
|
||||
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
|
||||
import {
|
||||
GroupProtocolService,
|
||||
AddResponse as GroupAddResponse,
|
||||
UpdateResponse as GroupUpdateResponse
|
||||
UpdateResponse as GroupUpdateResponse,
|
||||
DelResponse as GroupDelResponse
|
||||
} from '@ucap-webmessenger/protocol-group';
|
||||
import {
|
||||
BuddyProtocolService,
|
||||
|
@ -462,11 +466,9 @@ export class Effects {
|
|||
});
|
||||
|
||||
if (addBuddyList.length > 0) {
|
||||
this.logger.debug('addBuddyList : ', addBuddyList);
|
||||
this.store.dispatch(addBuddy({ userSeqs: addBuddyList }));
|
||||
}
|
||||
|
||||
this.logger.debug('group buddy : ', action.trgtUserSeq);
|
||||
this.store.dispatch(
|
||||
updateGroup({
|
||||
// 0: 동료그룹SEQ(n)
|
||||
|
@ -534,12 +536,10 @@ export class Effects {
|
|||
});
|
||||
|
||||
if (addBuddyList.length > 0) {
|
||||
this.logger.debug('addBuddyList : ', addBuddyList);
|
||||
this.store.dispatch(addBuddy({ userSeqs: addBuddyList }));
|
||||
}
|
||||
|
||||
if (delBuddyInGroup.length > 0) {
|
||||
this.logger.debug('delBuddyInGroup', delBuddyInGroup);
|
||||
// 즐겨찾기 해제.
|
||||
delBuddyInGroup.forEach(buddySeq => {
|
||||
this.buddyProtocolService
|
||||
|
@ -568,6 +568,75 @@ export class Effects {
|
|||
{ 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(() =>
|
||||
this.actions$.pipe(
|
||||
ofType(addBuddy),
|
||||
|
|
|
@ -16,7 +16,8 @@ import {
|
|||
updateUnreadCount,
|
||||
createGroupSuccess,
|
||||
addBuddySuccess,
|
||||
delBuddySuccess
|
||||
delBuddySuccess,
|
||||
delGroupSuccess
|
||||
} from './actions';
|
||||
import {
|
||||
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) => {
|
||||
return {
|
||||
|
|
Loading…
Reference in New Issue
Block a user