diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.html
index 8a346140..b74b2f1c 100644
--- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.html
+++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.html
@@ -3,10 +3,14 @@
그룹
-
@@ -84,7 +88,7 @@
mat-menu-item
(click)="onClickProfileContextMenu('REGISTER_FAVORITE', userInfo)"
>
- 즐겨찾기 등록
+ 즐겨찾기 {{ userInfo.isFavorit ? '해제' : '등록' }}
대화하기
diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.ts
index 8f477c8c..bb8282c3 100644
--- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.ts
+++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.ts
@@ -1,16 +1,33 @@
import { UserSelectDialogType } from './../../../../types/userselect.dialog.type';
-import {
- CreateChatDialogComponent,
- CreateChatDialogData,
- CreateChatDialogResult
-} from './../../dialogs/chat/create-chat.dialog.component';
+import { MatMenuTrigger } from '@angular/material';
import { Component, OnInit, ViewChild, OnDestroy } from '@angular/core';
import { Observable, combineLatest, Subscription } from 'rxjs';
import { map, tap } from 'rxjs/operators';
-
import { Store, select } from '@ngrx/store';
+import * as AppStore from '@app/store';
+import * as ChatStore from '@app/store/messenger/chat';
+import * as QueryStore from '@app/store/messenger/query';
+import * as SyncStore from '@app/store/messenger/sync';
+
+import { NGXLogger } from 'ngx-logger';
+import { Company } from '@ucap-webmessenger/api-external';
+import { SessionStorageService } from '@ucap-webmessenger/web-storage';
+import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
+import { LoginInfo, KEY_LOGIN_INFO } from '@app/types';
+import { KEY_VER_INFO } from '@app/types/ver-info.type';
+import { ExpansionPanelComponent as GroupExpansionPanelComponent } from '@ucap-webmessenger/ui-group';
+
+import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
+import { UserInfo, GroupDetailData } from '@ucap-webmessenger/protocol-sync';
+import {
+ DeptSearchType,
+ UserInfoSS,
+ UserInfoF,
+ UserInfoDN
+} from '@ucap-webmessenger/protocol-query';
+
import {
ucapAnimations,
DialogService,
@@ -18,48 +35,16 @@ import {
ConfirmDialogComponent,
ConfirmDialogResult
} from '@ucap-webmessenger/ui';
-import { UserInfo, GroupDetailData } from '@ucap-webmessenger/protocol-sync';
-
-import * as AppStore from '@app/store';
-import * as ChatStore from '@app/store/messenger/chat';
-import * as QueryStore from '@app/store/messenger/query';
-import * as SyncStore from '@app/store/messenger/sync';
-import { NGXLogger } from 'ngx-logger';
-import { Company } from '@ucap-webmessenger/api-external';
-import { SessionStorageService } from '@ucap-webmessenger/web-storage';
-import { LoginInfo, KEY_LOGIN_INFO } from '@app/types';
-import { ExpansionPanelComponent as GroupExpansionPanelComponent } from '@ucap-webmessenger/ui-group';
import {
- CreateGroupDialogComponent,
- CreateGroupDialogData,
- CreateGroupDialogResult
-} from '@app/layouts/messenger/dialogs/group/create-group.dialog.component';
-import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
-import {
- DeptSearchType,
- UserInfoSS,
- UserInfoF,
- UserInfoDN
-} from '@ucap-webmessenger/protocol-query';
-import { MatMenuTrigger } from '@angular/material';
-import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
-import { KEY_VER_INFO } from '@app/types/ver-info.type';
-import {
- DeleteGroupDialogComponent,
- DeleteGroupDialogData,
- DeleteGroupDialogResult
-} from '@app/layouts/messenger/dialogs/group/delete-group.dialog.component';
-
+ CreateChatDialogComponent,
+ CreateChatDialogData,
+ CreateChatDialogResult
+} from './../../dialogs/chat/create-chat.dialog.component';
import {
EditGroupDialogComponent,
EditGroupDialogData,
EditGroupDialogResult
} from '@app/layouts/messenger/dialogs/group/edit-group.dialog.component';
-import {
- EditGroupMemberDialogComponent,
- EditGroupMemberDialogData,
- EditGroupMemberDialogResult
-} from '@app/layouts/messenger/dialogs/group/edit-group-member.dialog.component';
@Component({
selector: 'app-layout-chat-left-sidenav-group',
@@ -251,10 +236,7 @@ export class GroupComponent implements OnInit, OnDestroy {
);
}
- onClickProfileContextMenu(
- menuType: string,
- userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN
- ) {
+ onClickProfileContextMenu(menuType: string, userInfo: UserInfo | UserInfoF) {
this.logger.debug(
'onClickProfileContextMenu',
'menuType',
@@ -262,6 +244,16 @@ export class GroupComponent implements OnInit, OnDestroy {
'userInfo',
userInfo
);
+ switch (menuType) {
+ case 'REGISTER_FAVORITE':
+ this.store.dispatch(
+ SyncStore.updateBuddy({
+ seq: userInfo.seq,
+ isFavorit: !userInfo.isFavorit
+ })
+ );
+ break;
+ }
}
onContextMenuProfile(
diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/effects.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/effects.ts
index 42368032..45f74adb 100644
--- a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/effects.ts
+++ b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/effects.ts
@@ -31,19 +31,21 @@ import {
refreshRoom,
refreshRoomFailure,
refreshRoomSuccess,
- createGroup,
- createGroupSuccess,
- createGroupFailure,
createGroupAndBuddy,
addBuddy,
addBuddyFailure,
delBuddy,
delBuddyFailure,
+ delBuddySuccess,
+ updateBuddy,
+ updateBuddySuccess,
+ updateBuddyFailure,
+ createGroup,
+ createGroupSuccess,
+ createGroupFailure,
updateGroup,
updateGroupFailure,
updateGroupMember,
- updateBuddy,
- delBuddySuccess,
delGroup,
delGroupFailure,
delGroupSuccess
@@ -92,7 +94,8 @@ import {
import {
BuddyProtocolService,
AddResponse as BuddyAddResponse,
- DelResponse as BuddyDelResponse
+ DelResponse as BuddyDelResponse,
+ UpdateResponse as BuddyUpdateResponse
} from '@ucap-webmessenger/protocol-buddy';
import * as ChatStore from '@app/store/messenger/chat';
@@ -682,6 +685,20 @@ export class Effects {
)
);
+ updateBuddy$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(updateBuddy),
+ exhaustMap(req =>
+ this.buddyProtocolService.update(req).pipe(
+ map((res: BuddyUpdateResponse) => {
+ return updateBuddySuccess(res);
+ }),
+ catchError(error => of(updateBuddyFailure({ error })))
+ )
+ )
+ )
+ );
+
updateGroup$ = createEffect(() =>
this.actions$.pipe(
ofType(updateGroup),
diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts
index 599c9790..4ce8d801 100644
--- a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts
+++ b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts
@@ -17,17 +17,20 @@ import {
createGroupSuccess,
addBuddySuccess,
delBuddySuccess,
- delGroupSuccess
+ delGroupSuccess,
+ updateBuddySuccess
} from './actions';
import {
RoomUserDetailData,
RoomUserData,
- GroupDetailData
+ GroupDetailData,
+ UserInfo
} from '@ucap-webmessenger/protocol-sync';
import * as AuthenticationStore from '@app/store/account/authentication';
import * as RoomStore from '@app/store/messenger/room';
import { RoomInfo } from '@ucap-webmessenger/protocol-room';
+import { UpdateResponse } from '@ucap-webmessenger/protocol-buddy';
export const reducer = createReducer(
initialState,
@@ -222,5 +225,17 @@ export const reducer = createReducer(
...state.buddy2
})
};
+ }),
+
+ on(updateBuddySuccess, (state, action) => {
+ const userInfo: UserInfo = {
+ ...state.buddy2.entities[action.seq],
+ isFavorit: action.isFavorit
+ };
+
+ return {
+ ...state,
+ buddy2: adapterBuddy2.upsertOne(userInfo, { ...state.buddy2 })
+ };
})
);