Rocket.Chat.ReactNative/app/lib/encryption/helpers/mapMessageFromApi.ts

15 lines
413 B
TypeScript

import { IMessage } from '../../../definitions';
export const mapMessageFromAPI = ({ attachments, tlm, ts, _updatedAt, ...message }: IMessage) => ({
...message,
ts: new Date(ts),
...(tlm && { tlm: new Date(tlm) }),
_updatedAt: new Date(_updatedAt),
...(attachments && {
attachments: attachments.map(({ ts, ...attachment }) => ({
...(ts && { ts: new Date(ts) }),
...(attachment as any)
}))
})
});