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 89a2aa32..f1f11d22 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 @@ -170,6 +170,7 @@ export class GroupComponent implements OnInit, OnDestroy { const tempOrderArr: GroupDetailData[] = []; let myDeptGroup: GroupDetailData; let defaultGroup: GroupDetailData; + const normalGroup: GroupDetailData[] = []; groupList.forEach(group => { if ( @@ -178,10 +179,10 @@ export class GroupComponent implements OnInit, OnDestroy { group.seq ) { myDeptGroup = group; - } - - if (0 === group.seq) { + } else if (0 === group.seq) { defaultGroup = group; + } else { + normalGroup.push(group); } }); @@ -190,16 +191,9 @@ export class GroupComponent implements OnInit, OnDestroy { } tempOrderArr.push( - ...groupList - .filter( - group => - group.seq !== - environment.productConfig.CommonSetting.myDeptGroupSeq && - group.seq !== 0 - ) - .sort((a, b) => - a.name < b.name ? -1 : a.name > b.name ? 1 : 0 - ) + ...normalGroup.sort((a, b) => + a.name < b.name ? -1 : a.name > b.name ? 1 : 0 + ) ); if (!!defaultGroup) { diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.ts index 44728c47..5d5e39cf 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.ts @@ -63,6 +63,7 @@ import { AlertDialogData } from '@ucap-webmessenger/ui'; import { TranslateService } from '@ngx-translate/core'; +import { environment } from '../../../../../environments/environment'; export interface CreateChatDialogData { type?: string; @@ -187,6 +188,45 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy { ) ]).pipe( map(([buddyList, groupList]) => { + // sort.. + if (!!groupList && groupList.length > 0) { + const tempOrderArr: GroupDetailData[] = []; + let myDeptGroup: GroupDetailData; + let defaultGroup: GroupDetailData; + const normalGroup: GroupDetailData[] = []; + + groupList.forEach(group => { + if ( + !!environment.productConfig.CommonSetting + .useMyDeptGroup && + environment.productConfig.CommonSetting + .myDeptGroupSeq === group.seq + ) { + myDeptGroup = group; + } else if (0 === group.seq) { + defaultGroup = group; + } else { + normalGroup.push(group); + } + }); + + if (!!myDeptGroup) { + tempOrderArr.push(myDeptGroup); + } + + tempOrderArr.push( + ...normalGroup.sort((a, b) => + a.name < b.name ? -1 : a.name > b.name ? 1 : 0 + ) + ); + + if (!!defaultGroup) { + tempOrderArr.push(defaultGroup); + } + + groupList = tempOrderArr; + } + const groupBuddyList: { group: GroupDetailData; buddyList: UserInfo[]; diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/state.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/state.ts index cda671c5..1987369f 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/state.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/state.ts @@ -5,11 +5,11 @@ import { UserInfo, GroupDetailData, RoomUserData, - RoomUserDetailData, + RoomUserDetailData } from '@ucap-webmessenger/protocol-sync'; import { RoomInfo, - UserInfo as RoomUserInfo, + UserInfo as RoomUserInfo } from '@ucap-webmessenger/protocol-room'; export interface Buddy2State extends EntityState { @@ -38,26 +38,10 @@ export interface State { } export const adapterBuddy2 = createEntityAdapter({ - selectId: userInfo => userInfo.seq, + selectId: userInfo => userInfo.seq }); export const adapterGroup2 = createEntityAdapter({ - selectId: groupDetailData => groupDetailData.seq, - sortComparer: (a, b) => { - // 기본그룹은 제일 하단 - if (0 === a.seq) { - return 1; - } else if (0 === b.seq) { - return -1; - } else { - if (a.name > b.name) { - return 1; - } - if (b.name > a.name) { - return -1; - } - return 0; - } - }, + selectId: groupDetailData => groupDetailData.seq }); export const adapterRoom = createEntityAdapter({ selectId: roomInfo => roomInfo.roomSeq, @@ -70,23 +54,23 @@ export const adapterRoom = createEntityAdapter({ .toDate() .getTime() ); - }, + } }); export const adapterRoomUser = createEntityAdapter({ - selectId: roomUserDetailData => roomUserDetailData.roomSeq, + selectId: roomUserDetailData => roomUserDetailData.roomSeq }); export const adapterRoomUserShort = createEntityAdapter({ - selectId: roomUserData => roomUserData.roomSeq, + selectId: roomUserData => roomUserData.roomSeq }); const buddy2InitialState: Buddy2State = adapterBuddy2.getInitialState({ - syncDate: '', + syncDate: '' }); const group2InitialState: Group2State = adapterGroup2.getInitialState({ - syncDate: '', + syncDate: '' }); const roomInitialState: RoomState = adapterRoom.getInitialState({ - syncDate: '', + syncDate: '' }); const roomUserInitialState: RoomUserState = adapterRoomUser.getInitialState({}); const roomUserShortInitialState: RoomUserShortState = adapterRoomUserShort.getInitialState( @@ -99,42 +83,42 @@ export const initialState: State = { room: roomInitialState, roomUser: roomUserInitialState, roomUserShort: roomUserShortInitialState, - chatUnreadCount: 0, + chatUnreadCount: 0 }; const { selectAll: ngeSelectAllBuddy2, selectEntities: ngeSelectEntitiesBuddy2, selectIds: ngeSelectIdsBuddy2, - selectTotal: ngeSelectTotalBuddy2, + selectTotal: ngeSelectTotalBuddy2 } = adapterBuddy2.getSelectors(); const { selectAll: ngeSelectAllGroup2, selectEntities: ngeSelectEntitiesGroup2, selectIds: ngeSelectIdsGroup2, - selectTotal: ngeSelectTotalGroup2, + selectTotal: ngeSelectTotalGroup2 } = adapterGroup2.getSelectors(); const { selectAll: ngeSelectAllRoom, selectEntities: ngeSelectEntitiesRoom, selectIds: ngeSelectIdsRoom, - selectTotal: ngeSelectTotalRoom, + selectTotal: ngeSelectTotalRoom } = adapterRoom.getSelectors(); const { selectAll: ngeSelectAllRoomUser, selectEntities: ngeSelectEntitiesRoomUser, selectIds: ngeSelectIdsRoomUser, - selectTotal: ngeSelectTotalRoomUser, + selectTotal: ngeSelectTotalRoomUser } = adapterRoomUser.getSelectors(); const { selectAll: ngeSelectAllRoomUserShort, selectEntities: ngeSelectEntitiesRoomUserShort, selectIds: ngeSelectIdsRoomUserShort, - selectTotal: ngeSelectTotalRoomUserShort, + selectTotal: ngeSelectTotalRoomUserShort } = adapterRoomUserShort.getSelectors(); export function selectors(selector: Selector) { @@ -178,6 +162,6 @@ export function selectors(selector: Selector) { selectChatUnreadCount: createSelector( selector, (state: State) => state.chatUnreadCount - ), + ) }; }