bigbuffet-rw/app/soapbox/normalizers/chat_message.ts
marcin mikołajczak b5ae9adf63 Chats: typescript
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2022-04-12 18:52:56 +02:00

29 lines
639 B
TypeScript

import {
List as ImmutableList,
Map as ImmutableMap,
Record as ImmutableRecord,
fromJS,
} from 'immutable';
import type { Attachment, Card, Emoji } from 'soapbox/types/entities';
export const ChatMessageRecord = ImmutableRecord({
account_id: '',
attachment: null as Attachment | null,
card: null as Card | null,
chat_id: '',
content: '',
created_at: new Date(),
emojis: ImmutableList<Emoji>(),
id: '',
unread: false,
deleting: false,
pending: false,
});
export const normalizeChatMessage = (chatMessage: Record<string, any>) => {
return ChatMessageRecord(
ImmutableMap(fromJS(chatMessage)),
);
};