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

18 lines
542 B
TypeScript

import { Map as ImmutableMap, Record as ImmutableRecord, fromJS } from 'immutable';
import type { ReducerAccount } from 'soapbox/reducers/accounts';
import type { Account, EmbeddedEntity } from 'soapbox/types/entities';
export const ChatRecord = ImmutableRecord({
account: null as EmbeddedEntity<Account | ReducerAccount>,
id: '',
unread: 0,
last_message: '' as string || null,
updated_at: new Date(),
});
export const normalizeChat = (chat: Record<string, any>) => {
return ChatRecord(
ImmutableMap(fromJS(chat)),
);
};