Chats: normalize chat messages again so attachments don't break
This commit is contained in:
parent
9802257751
commit
4d9f7fec32
2 changed files with 4 additions and 3 deletions
|
@ -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>) => {
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Loading…
Reference in a new issue