2022-04-12 09:52:56 -07:00
|
|
|
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,
|
2022-09-21 15:52:20 -07:00
|
|
|
updated_at: '',
|
2022-04-12 09:52:56 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
export const normalizeChat = (chat: Record<string, any>) => {
|
|
|
|
return ChatRecord(
|
|
|
|
ImmutableMap(fromJS(chat)),
|
|
|
|
);
|
|
|
|
};
|