Chats: normalize chat messages again so attachments don't break

This commit is contained in:
Alex Gleason 2022-11-02 14:23:39 -05:00
parent 9802257751
commit 4d9f7fec32
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 4 additions and 3 deletions

View file

@ -15,13 +15,13 @@ export const ChatMessageRecord = ImmutableRecord({
card: null as Card | null, card: null as Card | null,
chat_id: '', chat_id: '',
content: '', content: '',
created_at: new Date(), created_at: '',
emojis: ImmutableList<Emoji>(), emojis: ImmutableList<Emoji>(),
id: '', id: '',
unread: false, unread: false,
deleting: false, deleting: false,
pending: false, pending: false as boolean | undefined,
}); });
const normalizeMedia = (status: ImmutableMap<string, any>) => { const normalizeMedia = (status: ImmutableMap<string, any>) => {

View file

@ -9,6 +9,7 @@ import compareId from 'soapbox/compare_id';
import { useChatContext } from 'soapbox/contexts/chat-context'; import { useChatContext } from 'soapbox/contexts/chat-context';
import { useStatContext } from 'soapbox/contexts/stat-context'; import { useStatContext } from 'soapbox/contexts/stat-context';
import { useApi, useAppDispatch, useAppSelector, useFeatures } from 'soapbox/hooks'; import { useApi, useAppDispatch, useAppSelector, useFeatures } from 'soapbox/hooks';
import { normalizeChatMessage } from 'soapbox/normalizers';
import { flattenPages, PaginatedResult, updatePageItem } from 'soapbox/utils/queries'; import { flattenPages, PaginatedResult, updatePageItem } from 'soapbox/utils/queries';
import { queryClient } from './client'; import { queryClient } from './client';
@ -91,7 +92,7 @@ const useChatMessages = (chat: IChat) => {
const link = getNextLink(response); const link = getNextLink(response);
const hasMore = !!link; const hasMore = !!link;
const result = data.sort(reverseOrder); const result = data.sort(reverseOrder).map(normalizeChatMessage);
return { return {
result, result,