delete of message is added

This commit is contained in:
병준 박 2019-12-23 16:47:20 +09:00
parent 6f9702f3db
commit daa4bc2ba9

View File

@ -24,7 +24,7 @@ import {
QueryProtocolService QueryProtocolService
} from '@ucap-webmessenger/protocol-query'; } from '@ucap-webmessenger/protocol-query';
import { StatusProtocolService } from '@ucap-webmessenger/protocol-status'; import { StatusProtocolService } from '@ucap-webmessenger/protocol-status';
import { StatusType, StatusCode } from '@ucap-webmessenger/core'; import { StatusType, StatusCode, DeviceType } from '@ucap-webmessenger/core';
import { import {
DialogService, DialogService,
ConfirmDialogComponent, ConfirmDialogComponent,
@ -53,7 +53,9 @@ import { SessionStorageService } from '@ucap-webmessenger/web-storage';
import { import {
MessageApiService, MessageApiService,
MessageType, MessageType,
DetailRequest DetailRequest,
MessageDetailInfo,
DelRequest
} from '@ucap-webmessenger/api-message'; } from '@ucap-webmessenger/api-message';
import { MessageStatusCode } from '@ucap-webmessenger/api'; import { MessageStatusCode } from '@ucap-webmessenger/api';
import { import {
@ -166,10 +168,10 @@ export class MainPageComponent implements OnInit, OnDestroy {
} as DetailRequest) } as DetailRequest)
.pipe( .pipe(
take(1), take(1),
map(res => { map(async res => {
if (res.responseCode === MessageStatusCode.Success) { if (res.responseCode === MessageStatusCode.Success) {
// detail view.. // detail view..
this.dialogService.open< const result = await this.dialogService.open<
MessageDetailDialogComponent, MessageDetailDialogComponent,
MessageDetailDialogData, MessageDetailDialogData,
MessageDetailDialogResult MessageDetailDialogResult
@ -182,7 +184,14 @@ export class MainPageComponent implements OnInit, OnDestroy {
} }
}); });
// this.changeDetectorRef.detectChanges(); if (!!result) {
switch (result.returnType) {
case 'DEL':
// 단건 삭제.
this.doMessageDelete([result.messageInfo]);
break;
}
}
} else { } else {
} }
}), }),
@ -377,4 +386,29 @@ export class MainPageComponent implements OnInit, OnDestroy {
onCloseRightDrawer() { onCloseRightDrawer() {
this.rightDrawer.close(); this.rightDrawer.close();
} }
/** 쪽지(수신,발신) 삭제 */
doMessageDelete(messageInfo: MessageDetailInfo[]): void {
const msgList: { msgId: number }[] = [];
messageInfo.forEach(info => msgList.push({ msgId: info.msgId }));
this.messageApiService
.deleteMessage({
userSeq: this.loginRes.userSeq,
deviceType: DeviceType.PC,
tokenKey: this.loginRes.tokenString,
type: messageInfo[0].type,
msgList
} as DelRequest)
.pipe(
take(1),
map(async res => {
if (res.responseCode === MessageStatusCode.Success) {
} else {
this.logger.error('message delete Error!');
}
}),
catchError(error => of(this.logger.error(error)))
)
.subscribe();
}
} }