Normalize chat in reducer, not action

next-old
Alex Gleason 2022-03-10 21:09:12 -06:00
rodzic 92b86efb9b
commit 9547a7042d
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
2 zmienionych plików z 10 dodań i 11 usunięć

Wyświetl plik

@ -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;
}

Wyświetl plik

@ -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) =>