This commit is contained in:
khk 2019-11-13 18:36:26 +09:00
commit 01b59d9bfb
10 changed files with 125 additions and 89 deletions

View File

@ -5,5 +5,6 @@ services:
image: nginx:1.17.5-alpine image: nginx:1.17.5-alpine
volumes: volumes:
- ../dist/ucap-webmessenger-app:/usr/share/nginx/html:ro - ../dist/ucap-webmessenger-app:/usr/share/nginx/html:ro
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
ports: ports:
- 8099:80 - 8099:80

40
docker/nginx/nginx.conf Normal file
View File

@ -0,0 +1,40 @@
worker_processes 4;
events { worker_connections 1024; }
http {
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 30m;
#See http://blog.argteam.com/coding/hardening-node-js-for-production-part-2-using-nginx-to-avoid-node-js-load
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
proxy_temp_path /var/tmp;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_comp_level 6;
gzip_vary on;
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_buffers 16 8k;
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html;
expires -1;
add_header Pragma "no-cache";
add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
try_files $uri$args $uri$args/ $uri $uri/ /index.html =404;
}
}
}

View File

@ -1,6 +1,6 @@
import { import {
CommonApiService, CommonApiService,
MassTalkSaveRequest MassTalkSaveRequest,
} from '@ucap-webmessenger/api-common'; } from '@ucap-webmessenger/api-common';
import { KEY_ENVIRONMENTS_INFO } from './../../../types/environment.type'; import { KEY_ENVIRONMENTS_INFO } from './../../../types/environment.type';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
@ -19,8 +19,9 @@ import {
catchError, catchError,
exhaustMap, exhaustMap,
withLatestFrom, withLatestFrom,
concatMap concatMap,
} from 'rxjs/operators'; } from 'rxjs/operators';
import moment from 'moment';
import { import {
InfoData, InfoData,
Info, Info,
@ -37,7 +38,7 @@ import {
ReadNotification, ReadNotification,
SSVC_TYPE_EVENT_SEND_RES, SSVC_TYPE_EVENT_SEND_RES,
SSVC_TYPE_EVENT_SEND_NOTI, SSVC_TYPE_EVENT_SEND_NOTI,
EventJson EventJson,
} from '@ucap-webmessenger/protocol-event'; } from '@ucap-webmessenger/protocol-event';
import * as ChatStore from '@app/store/messenger/chat'; import * as ChatStore from '@app/store/messenger/chat';
@ -73,13 +74,13 @@ import {
infoIntervalClear, infoIntervalClear,
fileInfo, fileInfo,
fileInfoSuccess, fileInfoSuccess,
fileInfoFailure fileInfoFailure,
} from './actions'; } from './actions';
import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { SessionStorageService } from '@ucap-webmessenger/web-storage';
import { import {
RoomInfo, RoomInfo,
RoomProtocolService, RoomProtocolService,
OpenResponse OpenResponse,
} from '@ucap-webmessenger/protocol-room'; } from '@ucap-webmessenger/protocol-room';
import { LoginInfo, KEY_LOGIN_INFO, EnvironmentsInfo } from '@app/types'; import { LoginInfo, KEY_LOGIN_INFO, EnvironmentsInfo } from '@app/types';
import { Dictionary } from '@ngrx/entity'; import { Dictionary } from '@ngrx/entity';
@ -98,7 +99,7 @@ import {
InfoData as FileInfoData, InfoData as FileInfoData,
InfoCheckData as FileInfoCheckData, InfoCheckData as FileInfoCheckData,
InfoResponse as FileInfoResponse, InfoResponse as FileInfoResponse,
FileType FileType,
} from '@ucap-webmessenger/protocol-file'; } from '@ucap-webmessenger/protocol-file';
@Injectable() @Injectable()
@ -110,7 +111,7 @@ export class Effects {
return info({ return info({
roomSeq: action.roomSeq, roomSeq: action.roomSeq,
baseSeq: 0, baseSeq: 0,
requestCount: CONST.EVENT_INFO_READ_COUNT requestCount: CONST.EVENT_INFO_READ_COUNT,
}); });
}) })
) )
@ -138,14 +139,14 @@ export class Effects {
this.store.dispatch( this.store.dispatch(
infoSuccess({ infoSuccess({
infoList, infoList,
res: res as InfoResponse res: res as InfoResponse,
}) })
); );
} else { } else {
this.store.dispatch( this.store.dispatch(
infoMoreSuccess({ infoMoreSuccess({
infoList, infoList,
res: res as InfoResponse res: res as InfoResponse,
}) })
); );
} }
@ -160,7 +161,7 @@ export class Effects {
this.store.dispatch( this.store.dispatch(
read({ read({
roomSeq: req.roomSeq, roomSeq: req.roomSeq,
lastReadSeq: Number(maxSeq) lastReadSeq: Number(maxSeq),
}) })
); );
@ -170,8 +171,8 @@ export class Effects {
req: { req: {
roomSeq: req.roomSeq, roomSeq: req.roomSeq,
// { 파일타입 } cf) I : 이미지 V: 동영상 F: 파일 "" 빈값이면 모든 타입을 내려줌 // { 파일타입 } cf) I : 이미지 V: 동영상 F: 파일 "" 빈값이면 모든 타입을 내려줌
type: FileType.All type: FileType.All,
} },
}) })
); );
} }
@ -216,7 +217,7 @@ export class Effects {
fileInfoSuccess({ fileInfoSuccess({
fileInfoList, fileInfoList,
fileInfoCheckList, fileInfoCheckList,
res: res as FileInfoResponse res: res as FileInfoResponse,
}) })
); );
} }
@ -255,7 +256,10 @@ export class Effects {
for (const key in eventList) { for (const key in eventList) {
const event: Info<EventJson> = eventList[key]; const event: Info<EventJson> = eventList[key];
if ( if (
new Date().getTime() - new Date(event.sendDate).getTime() >= new Date().getTime() -
moment(event.sendDate)
.toDate()
.getTime() >=
roomInfo.timeRoomInterval * 1000 roomInfo.timeRoomInterval * 1000
) { ) {
delEventSeq.push(event.seq); delEventSeq.push(event.seq);
@ -317,7 +321,7 @@ export class Effects {
this.store.dispatch( this.store.dispatch(
SyncStore.updateUnreadCount({ SyncStore.updateUnreadCount({
roomSeq: action.roomSeq, roomSeq: action.roomSeq,
noReadCnt: 0 noReadCnt: 0,
}) })
); );
} }
@ -335,7 +339,7 @@ export class Effects {
map((res: SendResponse) => { map((res: SendResponse) => {
return sendSuccess({ return sendSuccess({
senderSeq: action.senderSeq, senderSeq: action.senderSeq,
res res,
}); });
}), }),
catchError(error => of(sendFailure({ error }))) catchError(error => of(sendFailure({ error })))
@ -356,7 +360,7 @@ export class Effects {
roomSeq: res.roomSeq, roomSeq: res.roomSeq,
info: res.info, info: res.info,
SVC_TYPE: res.SVC_TYPE, SVC_TYPE: res.SVC_TYPE,
SSVC_TYPE: res.SSVC_TYPE SSVC_TYPE: res.SSVC_TYPE,
}) })
); );
}) })
@ -376,7 +380,7 @@ export class Effects {
roomSeq: noti.roomSeq, roomSeq: noti.roomSeq,
info: noti.info, info: noti.info,
SVC_TYPE: noti.SVC_TYPE, SVC_TYPE: noti.SVC_TYPE,
SSVC_TYPE: noti.SSVC_TYPE SSVC_TYPE: noti.SSVC_TYPE,
}) })
); );
}) })
@ -400,8 +404,8 @@ export class Effects {
req: { req: {
roomSeq: action.trgtRoomSeq, roomSeq: action.trgtRoomSeq,
eventType: action.req.eventType, eventType: action.req.eventType,
sentMessage: action.req.sentMessage sentMessage: action.req.sentMessage,
} },
}) })
); );
} else if (!!action.trgtUserSeqs && action.trgtUserSeqs.length > 0) { } else if (!!action.trgtUserSeqs && action.trgtUserSeqs.length > 0) {
@ -421,7 +425,7 @@ export class Effects {
return this.roomProtocolService return this.roomProtocolService
.open({ .open({
divCd: 'forwardOpen', divCd: 'forwardOpen',
userSeqs: action.trgtUserSeqs userSeqs: action.trgtUserSeqs,
}) })
.pipe( .pipe(
map((res: OpenResponse) => { map((res: OpenResponse) => {
@ -434,8 +438,8 @@ export class Effects {
req: { req: {
roomSeq: res.res.roomSeq, roomSeq: res.res.roomSeq,
eventType: action.req.eventType, eventType: action.req.eventType,
sentMessage: action.req.sentMessage sentMessage: action.req.sentMessage,
} },
}) })
); );
return res; return res;
@ -464,7 +468,7 @@ export class Effects {
deviceType: environmentsInfo.deviceType, deviceType: environmentsInfo.deviceType,
token: loginResInfo.tokenString, token: loginResInfo.tokenString,
content: action.req.sentMessage, content: action.req.sentMessage,
roomSeq: action.req.roomSeq roomSeq: action.req.roomSeq,
}; };
return this.commonApiService.massTalkSave(req).pipe( return this.commonApiService.massTalkSave(req).pipe(
@ -476,8 +480,8 @@ export class Effects {
req: { req: {
roomSeq: res.roomSeq, roomSeq: res.roomSeq,
eventType: EventType.MassText, eventType: EventType.MassText,
sentMessage: res.returnJson sentMessage: res.returnJson,
} },
}) })
); );
} else { } else {
@ -519,7 +523,7 @@ export class Effects {
this.store.dispatch( this.store.dispatch(
read({ read({
roomSeq: action.roomSeq, roomSeq: action.roomSeq,
lastReadSeq: action.info.seq lastReadSeq: action.info.seq,
}) })
); );
} }
@ -541,7 +545,7 @@ export class Effects {
this.store.dispatch( this.store.dispatch(
SyncStore.updateUnreadCount({ SyncStore.updateUnreadCount({
roomSeq: action.roomSeq, roomSeq: action.roomSeq,
noReadCnt: noReadCnt + 1 noReadCnt: noReadCnt + 1,
}) })
); );
} }
@ -594,7 +598,7 @@ export class Effects {
SyncStore.refreshRoom({ SyncStore.refreshRoom({
roomSeq: action.noti.roomSeq, roomSeq: action.noti.roomSeq,
isDetail: true, isDetail: true,
localeCode: loginInfo.localeCode localeCode: loginInfo.localeCode,
}) })
); );
}) })
@ -641,7 +645,7 @@ export class Effects {
SyncStore.refreshRoom({ SyncStore.refreshRoom({
roomSeq: noti.roomSeq, roomSeq: noti.roomSeq,
isDetail: true, isDetail: true,
localeCode: loginInfo.localeCode localeCode: loginInfo.localeCode,
}) })
); );
}) })

View File

@ -1,14 +1,15 @@
import { Selector, createSelector } from '@ngrx/store'; import { Selector, createSelector } from '@ngrx/store';
import { EntityState, createEntityAdapter } from '@ngrx/entity'; import { EntityState, createEntityAdapter } from '@ngrx/entity';
import moment from 'moment';
import { import {
UserInfo, UserInfo,
GroupDetailData, GroupDetailData,
RoomUserData, RoomUserData,
RoomUserDetailData RoomUserDetailData,
} from '@ucap-webmessenger/protocol-sync'; } from '@ucap-webmessenger/protocol-sync';
import { import {
RoomInfo, RoomInfo,
UserInfo as RoomUserInfo UserInfo as RoomUserInfo,
} from '@ucap-webmessenger/protocol-room'; } from '@ucap-webmessenger/protocol-room';
export interface Buddy2State extends EntityState<UserInfo> { export interface Buddy2State extends EntityState<UserInfo> {
@ -37,7 +38,7 @@ export interface State {
} }
export const adapterBuddy2 = createEntityAdapter<UserInfo>({ export const adapterBuddy2 = createEntityAdapter<UserInfo>({
selectId: userInfo => userInfo.seq selectId: userInfo => userInfo.seq,
}); });
export const adapterGroup2 = createEntityAdapter<GroupDetailData>({ export const adapterGroup2 = createEntityAdapter<GroupDetailData>({
selectId: groupDetailData => groupDetailData.seq, selectId: groupDetailData => groupDetailData.seq,
@ -56,32 +57,36 @@ export const adapterGroup2 = createEntityAdapter<GroupDetailData>({
} }
return 0; return 0;
} }
} },
}); });
export const adapterRoom = createEntityAdapter<RoomInfo>({ export const adapterRoom = createEntityAdapter<RoomInfo>({
selectId: roomInfo => roomInfo.roomSeq, selectId: roomInfo => roomInfo.roomSeq,
sortComparer: (a, b) => { sortComparer: (a, b) => {
return ( return (
new Date(b.finalEventDate).getTime() - moment(b.finalEventDate)
new Date(a.finalEventDate).getTime() .toDate()
.getTime() -
moment(a.finalEventDate)
.toDate()
.getTime()
); );
} },
}); });
export const adapterRoomUser = createEntityAdapter<RoomUserDetailData>({ export const adapterRoomUser = createEntityAdapter<RoomUserDetailData>({
selectId: roomUserDetailData => roomUserDetailData.roomSeq selectId: roomUserDetailData => roomUserDetailData.roomSeq,
}); });
export const adapterRoomUserShort = createEntityAdapter<RoomUserData>({ export const adapterRoomUserShort = createEntityAdapter<RoomUserData>({
selectId: roomUserData => roomUserData.roomSeq selectId: roomUserData => roomUserData.roomSeq,
}); });
const buddy2InitialState: Buddy2State = adapterBuddy2.getInitialState({ const buddy2InitialState: Buddy2State = adapterBuddy2.getInitialState({
syncDate: '' syncDate: '',
}); });
const group2InitialState: Group2State = adapterGroup2.getInitialState({ const group2InitialState: Group2State = adapterGroup2.getInitialState({
syncDate: '' syncDate: '',
}); });
const roomInitialState: RoomState = adapterRoom.getInitialState({ const roomInitialState: RoomState = adapterRoom.getInitialState({
syncDate: '' syncDate: '',
}); });
const roomUserInitialState: RoomUserState = adapterRoomUser.getInitialState({}); const roomUserInitialState: RoomUserState = adapterRoomUser.getInitialState({});
const roomUserShortInitialState: RoomUserShortState = adapterRoomUserShort.getInitialState( const roomUserShortInitialState: RoomUserShortState = adapterRoomUserShort.getInitialState(
@ -94,59 +99,50 @@ export const initialState: State = {
room: roomInitialState, room: roomInitialState,
roomUser: roomUserInitialState, roomUser: roomUserInitialState,
roomUserShort: roomUserShortInitialState, roomUserShort: roomUserShortInitialState,
chatUnreadCount: 0 chatUnreadCount: 0,
}; };
const { const {
selectAll: ngeSelectAllBuddy2, selectAll: ngeSelectAllBuddy2,
selectEntities: ngeSelectEntitiesBuddy2, selectEntities: ngeSelectEntitiesBuddy2,
selectIds: ngeSelectIdsBuddy2, selectIds: ngeSelectIdsBuddy2,
selectTotal: ngeSelectTotalBuddy2 selectTotal: ngeSelectTotalBuddy2,
} = adapterBuddy2.getSelectors(); } = adapterBuddy2.getSelectors();
const { const {
selectAll: ngeSelectAllGroup2, selectAll: ngeSelectAllGroup2,
selectEntities: ngeSelectEntitiesGroup2, selectEntities: ngeSelectEntitiesGroup2,
selectIds: ngeSelectIdsGroup2, selectIds: ngeSelectIdsGroup2,
selectTotal: ngeSelectTotalGroup2 selectTotal: ngeSelectTotalGroup2,
} = adapterGroup2.getSelectors(); } = adapterGroup2.getSelectors();
const { const {
selectAll: ngeSelectAllRoom, selectAll: ngeSelectAllRoom,
selectEntities: ngeSelectEntitiesRoom, selectEntities: ngeSelectEntitiesRoom,
selectIds: ngeSelectIdsRoom, selectIds: ngeSelectIdsRoom,
selectTotal: ngeSelectTotalRoom selectTotal: ngeSelectTotalRoom,
} = adapterRoom.getSelectors(); } = adapterRoom.getSelectors();
const { const {
selectAll: ngeSelectAllRoomUser, selectAll: ngeSelectAllRoomUser,
selectEntities: ngeSelectEntitiesRoomUser, selectEntities: ngeSelectEntitiesRoomUser,
selectIds: ngeSelectIdsRoomUser, selectIds: ngeSelectIdsRoomUser,
selectTotal: ngeSelectTotalRoomUser selectTotal: ngeSelectTotalRoomUser,
} = adapterRoomUser.getSelectors(); } = adapterRoomUser.getSelectors();
const { const {
selectAll: ngeSelectAllRoomUserShort, selectAll: ngeSelectAllRoomUserShort,
selectEntities: ngeSelectEntitiesRoomUserShort, selectEntities: ngeSelectEntitiesRoomUserShort,
selectIds: ngeSelectIdsRoomUserShort, selectIds: ngeSelectIdsRoomUserShort,
selectTotal: ngeSelectTotalRoomUserShort selectTotal: ngeSelectTotalRoomUserShort,
} = adapterRoomUserShort.getSelectors(); } = adapterRoomUserShort.getSelectors();
export function selectors<S>(selector: Selector<any, State>) { export function selectors<S>(selector: Selector<any, State>) {
const selectBuddy2 = createSelector( const selectBuddy2 = createSelector(selector, (state: State) => state.buddy2);
selector,
(state: State) => state.buddy2
);
const selectGroup2 = createSelector( const selectGroup2 = createSelector(selector, (state: State) => state.group2);
selector,
(state: State) => state.group2
);
const selectRoom = createSelector( const selectRoom = createSelector(selector, (state: State) => state.room);
selector,
(state: State) => state.room
);
const selectRoomUser = createSelector( const selectRoomUser = createSelector(
selector, selector,
@ -159,34 +155,22 @@ export function selectors<S>(selector: Selector<any, State>) {
); );
return { return {
selectAllBuddy2: createSelector( selectAllBuddy2: createSelector(selectBuddy2, ngeSelectAllBuddy2),
selectBuddy2,
ngeSelectAllBuddy2
),
selectBuddy2SyncDate: createSelector( selectBuddy2SyncDate: createSelector(
selectBuddy2, selectBuddy2,
buddy2State => buddy2State.syncDate buddy2State => buddy2State.syncDate
), ),
selectAllGroup2: createSelector( selectAllGroup2: createSelector(selectGroup2, ngeSelectAllGroup2),
selectGroup2,
ngeSelectAllGroup2
),
selectGroup2SyncDate: createSelector( selectGroup2SyncDate: createSelector(
selectGroup2, selectGroup2,
group2State => group2State.syncDate group2State => group2State.syncDate
), ),
selectAllRoom: createSelector( selectAllRoom: createSelector(selectRoom, ngeSelectAllRoom),
selectRoom,
ngeSelectAllRoom
),
selectRoomSyncDate: createSelector( selectRoomSyncDate: createSelector(
selectRoom, selectRoom,
roomState => roomState.syncDate roomState => roomState.syncDate
), ),
selectAllRoomUser: createSelector( selectAllRoomUser: createSelector(selectRoomUser, ngeSelectAllRoomUser),
selectRoomUser,
ngeSelectAllRoomUser
),
selectAllRoomUserShort: createSelector( selectAllRoomUserShort: createSelector(
selectRoomUserShort, selectRoomUserShort,
ngeSelectAllRoomUserShort ngeSelectAllRoomUserShort
@ -194,6 +178,6 @@ export function selectors<S>(selector: Selector<any, State>) {
selectChatUnreadCount: createSelector( selectChatUnreadCount: createSelector(
selector, selector,
(state: State) => state.chatUnreadCount (state: State) => state.chatUnreadCount
) ),
}; };
} }

View File

@ -1,11 +1,12 @@
import { Component, OnInit, Input } from '@angular/core'; import { Component, OnInit, Input } from '@angular/core';
import { Info, EventJson } from '@ucap-webmessenger/protocol-event'; import { Info, EventJson } from '@ucap-webmessenger/protocol-event';
import { DatePipe } from '@angular/common'; import { DatePipe } from '@angular/common';
import moment from 'moment';
@Component({ @Component({
selector: 'ucap-chat-message-box-date-splitter', selector: 'ucap-chat-message-box-date-splitter',
templateUrl: './date-splitter.component.html', templateUrl: './date-splitter.component.html',
styleUrls: ['./date-splitter.component.scss'] styleUrls: ['./date-splitter.component.scss'],
}) })
export class DateSplitterComponent implements OnInit { export class DateSplitterComponent implements OnInit {
@Input() @Input()
@ -17,7 +18,7 @@ export class DateSplitterComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.dateInfo = this.datePipe.transform( this.dateInfo = this.datePipe.transform(
this.message.sendDate, moment(this.message.sendDate).toDate(),
'yyyy.MM.dd EEE' 'yyyy.MM.dd EEE'
); );
} }

View File

@ -1,7 +1,7 @@
<div class="bubble-main"> <div class="bubble-main">
<span class="content" [innerHTML]="content | linefeedtohtml"></span> <span class="content" [innerHTML]="content | linefeedtohtml"></span>
<span> <span>
{{ message.sendDate | date: 'short' }} {{ moment(message.sendDate).toDate() | date: 'short' }}
</span> </span>
</div> </div>
<div *ngIf="detailButteonShow" class="btn-box"> <div *ngIf="detailButteonShow" class="btn-box">

View File

@ -2,11 +2,12 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Info, MassTextEventJson } from '@ucap-webmessenger/protocol-event'; import { Info, MassTextEventJson } from '@ucap-webmessenger/protocol-event';
import { NGXLogger } from 'ngx-logger'; import { NGXLogger } from 'ngx-logger';
import { StatusCode } from '@ucap-webmessenger/api'; import { StatusCode } from '@ucap-webmessenger/api';
import moment from 'moment';
@Component({ @Component({
selector: 'ucap-chat-message-box-mass', selector: 'ucap-chat-message-box-mass',
templateUrl: './mass.component.html', templateUrl: './mass.component.html',
styleUrls: ['./mass.component.scss'] styleUrls: ['./mass.component.scss'],
}) })
export class MassComponent implements OnInit { export class MassComponent implements OnInit {
@Input() @Input()
@ -19,6 +20,8 @@ export class MassComponent implements OnInit {
eventMassSeq: number; eventMassSeq: number;
detailButteonShow = true; detailButteonShow = true;
moment = moment;
constructor(private logger: NGXLogger) {} constructor(private logger: NGXLogger) {}
ngOnInit() { ngOnInit() {

View File

@ -154,7 +154,7 @@
<ul> <ul>
<li>{{ getUnreadCount(message) }}</li> <li>{{ getUnreadCount(message) }}</li>
<li> <li>
{{ message.sendDate | date: 'a hh:mm' }} {{ moment(message.sendDate).toDate() | date: 'a hh:mm' }}
</li> </li>
</ul> </ul>
</div> </div>

View File

@ -5,7 +5,7 @@ import {
Input, Input,
EventEmitter, EventEmitter,
Output, Output,
ViewEncapsulation ViewEncapsulation,
} from '@angular/core'; } from '@angular/core';
import { import {
@ -13,7 +13,7 @@ import {
EventType, EventType,
InfoResponse, InfoResponse,
EventJson, EventJson,
FileEventJson FileEventJson,
} from '@ucap-webmessenger/protocol-event'; } from '@ucap-webmessenger/protocol-event';
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
import { UserInfo } from '@ucap-webmessenger/protocol-room'; import { UserInfo } from '@ucap-webmessenger/protocol-room';
@ -21,11 +21,12 @@ import { NGXLogger } from 'ngx-logger';
import { VersionInfo2Response } from '@ucap-webmessenger/api-public'; import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
import { FileInfo } from '../models/file-info.json'; import { FileInfo } from '../models/file-info.json';
import { DatePipe } from '@angular/common'; import { DatePipe } from '@angular/common';
import moment from 'moment';
@Component({ @Component({
selector: 'ucap-chat-messages', selector: 'ucap-chat-messages',
templateUrl: './messages.component.html', templateUrl: './messages.component.html',
styleUrls: ['./messages.component.scss'] styleUrls: ['./messages.component.scss'],
}) })
export class MessagesComponent implements OnInit { export class MessagesComponent implements OnInit {
@Input() @Input()
@ -60,6 +61,7 @@ export class MessagesComponent implements OnInit {
EventType = EventType; EventType = EventType;
CONST = CONST; CONST = CONST;
profileImageRoot: string; profileImageRoot: string;
moment = moment;
constructor(private logger: NGXLogger, private datePipe: DatePipe) {} constructor(private logger: NGXLogger, private datePipe: DatePipe) {}
@ -147,11 +149,11 @@ export class MessagesComponent implements OnInit {
if (curIndex > 0) { if (curIndex > 0) {
return ( return (
this.datePipe.transform( this.datePipe.transform(
this.messages[curIndex].sendDate, moment(this.messages[curIndex].sendDate).toDate(),
'yyyyMMdd' 'yyyyMMdd'
) !== ) !==
this.datePipe.transform( this.datePipe.transform(
this.messages[curIndex - 1].sendDate, moment(this.messages[curIndex - 1].sendDate).toDate(),
'yyyyMMdd' 'yyyyMMdd'
) )
); );

View File

@ -1,5 +1,6 @@
import { Pipe, PipeTransform } from '@angular/core'; import { Pipe, PipeTransform } from '@angular/core';
import { StringUtil } from '../utils/string.util'; import { StringUtil } from '../utils/string.util';
import moment from 'moment';
@Pipe({ @Pipe({
name: 'dateToStringChatList', name: 'dateToStringChatList',
@ -10,7 +11,7 @@ export class DateToStringForChatRoomListPipe implements PipeTransform {
const yesterDate = new Date(curDate.getTime() - 1 * 24 * 60 * 60 * 1000); const yesterDate = new Date(curDate.getTime() - 1 * 24 * 60 * 60 * 1000);
let date: Date; let date: Date;
if (typeof value === 'string') { if (typeof value === 'string') {
date = new Date(value.toString()); date = moment(value.toString()).toDate();
} else if (value instanceof Date) { } else if (value instanceof Date) {
date = value; date = value;
} else { } else {
@ -42,7 +43,7 @@ export class DateToStringForChatRoomListPipe implements PipeTransform {
}) })
export class DateToStringFormatPipe implements PipeTransform { export class DateToStringFormatPipe implements PipeTransform {
transform(value: any, format?: string): string { transform(value: any, format?: string): string {
const date = new Date(value.toString()); const date = moment(value.toString()).toDate();
if (!!format) { if (!!format) {
return StringUtil.dateFormat(date, format); return StringUtil.dateFormat(date, format);