Skip to content

Commit

Permalink
made requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
osinkinroman committed Jun 27, 2022
1 parent 6c6b046 commit cb7e31f
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 42 deletions.
5 changes: 1 addition & 4 deletions src/api/sse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ export const toStream = (
name: string,
direction: MessageDirection[] = ['first', 'second'],
): string[] => {
const res = direction.map(dir => `${name}:${dir}`);

return res;
return direction.map(dir => `${name}:${dir}`);
};

export interface MessagesSSEParams extends BaseSSEParams {
Expand Down Expand Up @@ -201,7 +199,6 @@ export function getMessagesSSEParamsFromFilter(

const sseApi: SSESchema = {
getEventSource: config => {
// console.error(new Error());
const { type, queryParams } = config;
const params = createURLSearchParams({
...queryParams,
Expand Down
5 changes: 1 addition & 4 deletions src/components/embedded/EmbeddedEventHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export default function EmbeddedEventHeader(props: Props) {
const { eventId, eventName, eventType, startTimestamp, endTimestamp } = event;

const status = getEventStatus(event);
const startTimestampValue = timestampToNumber(startTimestamp);

const elapsedTime =
endTimestamp && startTimestamp ? getElapsedTime(startTimestamp, endTimestamp) : null;
Expand All @@ -52,9 +51,7 @@ export default function EmbeddedEventHeader(props: Props) {
<>
{elapsedTime && <span className='event-header-card__elapsed-time'>{elapsedTime}</span>}
<div className='event-header-card__time-label'>
<span className='event-header-card__time-label-full'>
{formatTime(startTimestampValue)}
</span>
<span className='event-header-card__time-label-full'>{formatTime(startTimestamp)}</span>
</div>
{eventType && <span className='event-header-card__event-type'>{eventType}</span>}
</>
Expand Down
18 changes: 10 additions & 8 deletions src/components/embedded/EmbeddedMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,25 @@ function EmbeddedMessage({ messageId }: { messageId: string }) {
}, []);

useEffect(() => {
if (message)
message.parsedMessages?.forEach((parsedMessage, index) => {
const tempMessage = message;
const { parsedMessages, ...rest } = tempMessage;
if (message?.parsedMessages) {
const tempMessageList: EventMessageItem[] = [];
message.parsedMessages.forEach(parsedMessage => {
const { parsedMessages, ...rest } = message;
const tempMessageItem: EventMessageItem = {
...rest,
parsedMessage: null,
parsedMessages: [],
};

tempMessageItem.parsedMessage = tempMessage.parsedMessages
? tempMessage.parsedMessages[index]
: null;
tempMessageItem.parsedMessage = message.parsedMessages ? parsedMessage : null;
if (tempMessageItem.parsedMessages && tempMessageItem.parsedMessage)
tempMessageItem.parsedMessages[0] = tempMessageItem.parsedMessage;
setMessageList([...messageList, tempMessageItem]);
tempMessageList.push(tempMessageItem);
});
setMessageList(messageList => [...messageList, ...tempMessageList]);
} else {
setMessageList(messageList => [...messageList, message as EventMessageItem]);
}
});

async function getMessage() {
Expand Down
7 changes: 2 additions & 5 deletions src/components/event/EventCardHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ function EventCardHeader(props: Props) {
const { stopSearch, setFormType, updateForm } = useSearchStore();

const status = isUnknown ? 'unknown' : getEventStatus(event);
const startTimestampValue = timestampToNumber(startTimestamp);

const elapsedTime =
endTimestamp && startTimestamp ? getElapsedTime(startTimestamp, endTimestamp) : null;
Expand Down Expand Up @@ -100,7 +99,7 @@ function EventCardHeader(props: Props) {
setFormType('event');
updateForm({
parentEvent: eventId,
startTimestamp: startTimestampValue,
startTimestamp: timestampToNumber(startTimestamp),
});
setActiveWorkspace(0);
}
Expand Down Expand Up @@ -129,9 +128,7 @@ function EventCardHeader(props: Props) {
<>
{elapsedTime && <span className='event-header-card__elapsed-time'>{elapsedTime}</span>}
<div className='event-header-card__time-label'>
<span className='event-header-card__time-label-full'>
{formatTime(startTimestampValue)}
</span>
<span className='event-header-card__time-label-full'>{formatTime(startTimestamp)}</span>
</div>
{eventType && (
<span className='event-header-card__event-type' onClick={handleTypeClick}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
***************************************************************************** */

import * as React from 'react';
import { toJS } from 'mobx';
import { Observer, observer } from 'mobx-react-lite';
import { Virtuoso, VirtuosoHandle, ListItem } from 'react-virtuoso';
import moment from 'moment';
Expand Down Expand Up @@ -102,26 +101,27 @@ const MessagesVirtualizedList = (props: Props) => {
]);

React.useEffect(() => {
toJS(messages).forEach(message =>
message.parsedMessages
? message.parsedMessages.forEach((parsedMessage, index) => {
const tempMessage = message;
const { parsedMessages, ...rest } = tempMessage;
const tempMessageItem: EventMessageItem = {
...rest,
parsedMessage: null,
parsedMessages: [],
};
messages.forEach(message => {
if (message.parsedMessages) {
const tempMessageList: EventMessageItem[] = [];
message.parsedMessages.forEach(parsedMessage => {
const { parsedMessages, ...rest } = message;
const tempMessageItem: EventMessageItem = {
...rest,
parsedMessage: null,
parsedMessages: [],
};

tempMessageItem.parsedMessage = tempMessage.parsedMessages
? tempMessage.parsedMessages[index]
: null;
if (tempMessageItem.parsedMessages && tempMessageItem.parsedMessage)
tempMessageItem.parsedMessages[0] = tempMessageItem.parsedMessage;
setMessageList(messageListCopy => [...messageListCopy, tempMessageItem]);
})
: setMessageList(messageListCopy => [...messageListCopy, message as EventMessageItem]),
);
tempMessageItem.parsedMessage = message.parsedMessages ? parsedMessage : null;
if (tempMessageItem.parsedMessages && tempMessageItem.parsedMessage)
tempMessageItem.parsedMessages[0] = tempMessageItem.parsedMessage;
tempMessageList.push(tempMessageItem);
});
setMessageList(messageList => [...messageList, ...tempMessageList]);
} else {
setMessageList(messageList => [...messageList, message as EventMessageItem]);
}
});
}, [messages]);

const debouncedScrollHandler = useDebouncedCallback(
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function formatTime(time: string | number) {
if (time == null) {
return '';
}
return moment.utc(time).format(DateTimeMask.DATE_TIME_MASK);
return moment.utc(new Date(time).getTime()).format(DateTimeMask.DATE_TIME_MASK);
}

export function timestampToNumber(timestamp: string): number {
Expand Down

0 comments on commit cb7e31f

Please sign in to comment.