Normalize chat in reducer, not action
This commit is contained in:
parent
92b86efb9b
commit
9547a7042d
|
@ -40,13 +40,3 @@ export function normalizeAccount(account) {
|
|||
|
||||
return account;
|
||||
}
|
||||
|
||||
export function normalizeChat(chat, normalOldChat) {
|
||||
const normalChat = { ...chat };
|
||||
const { account, last_message: lastMessage } = chat;
|
||||
|
||||
if (account) normalChat.account = account.id;
|
||||
if (lastMessage) normalChat.last_message = lastMessage.id;
|
||||
|
||||
return normalChat;
|
||||
}
|
||||
|
|
|
@ -9,9 +9,18 @@ import {
|
|||
CHAT_READ_SUCCESS,
|
||||
CHAT_READ_REQUEST,
|
||||
} from 'soapbox/actions/chats';
|
||||
import { normalizeChat } from 'soapbox/actions/importer/normalizer';
|
||||
import { STREAMING_CHAT_UPDATE } from 'soapbox/actions/streaming';
|
||||
|
||||
const normalizeChat = (chat, normalOldChat) => {
|
||||
const normalChat = { ...chat };
|
||||
const { account, last_message: lastMessage } = chat;
|
||||
|
||||
if (account) normalChat.account = account.id;
|
||||
if (lastMessage) normalChat.last_message = lastMessage.id;
|
||||
|
||||
return normalChat;
|
||||
};
|
||||
|
||||
const importChat = (state, chat) => state.setIn(['items', chat.id], fromJS(normalizeChat(chat)));
|
||||
|
||||
const importChats = (state, chats, next) =>
|
||||
|
|
Loading…
Reference in New Issue