Merge branch 'normal-chat-refactor' into 'develop'

Normalize chat in reducer, not action

See merge request soapbox-pub/soapbox-fe!1092
merge-requests/1093/merge
Alex Gleason 3 years ago
commit e5f1fae956

@ -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…
Cancel
Save