Merge branch 'fix-chat-attachments' into 'develop'
Normalize chat attachments See merge request soapbox-pub/soapbox!1824
This commit is contained in:
commit
74bee6a678
3 changed files with 14 additions and 6 deletions
|
@ -263,14 +263,13 @@ const Item: React.FC<IItem> = ({
|
||||||
interface IMediaGallery {
|
interface IMediaGallery {
|
||||||
sensitive?: boolean,
|
sensitive?: boolean,
|
||||||
media: ImmutableList<Attachment>,
|
media: ImmutableList<Attachment>,
|
||||||
size: number,
|
|
||||||
height: number,
|
height: number,
|
||||||
onOpenMedia: (media: ImmutableList<Attachment>, index: number) => void,
|
onOpenMedia: (media: ImmutableList<Attachment>, index: number) => void,
|
||||||
defaultWidth: number,
|
defaultWidth?: number,
|
||||||
cacheWidth: (width: number) => void,
|
cacheWidth?: (width: number) => void,
|
||||||
visible?: boolean,
|
visible?: boolean,
|
||||||
onToggleVisibility?: () => void,
|
onToggleVisibility?: () => void,
|
||||||
displayMedia: string,
|
displayMedia?: string,
|
||||||
compact: boolean,
|
compact: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,7 +277,7 @@ const MediaGallery: React.FC<IMediaGallery> = (props) => {
|
||||||
const {
|
const {
|
||||||
media,
|
media,
|
||||||
sensitive = false,
|
sensitive = false,
|
||||||
defaultWidth,
|
defaultWidth = 0,
|
||||||
onToggleVisibility,
|
onToggleVisibility,
|
||||||
onOpenMedia,
|
onOpenMedia,
|
||||||
cacheWidth,
|
cacheWidth,
|
||||||
|
|
|
@ -178,6 +178,7 @@ const ChatMessageList: React.FC<IChatMessageList> = ({ chatId, chatMessageIds, a
|
||||||
media={ImmutableList([attachment])}
|
media={ImmutableList([attachment])}
|
||||||
height={120}
|
height={120}
|
||||||
onOpenMedia={onOpenMedia}
|
onOpenMedia={onOpenMedia}
|
||||||
|
visible
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Bundle>
|
</Bundle>
|
||||||
|
|
|
@ -5,6 +5,8 @@ import {
|
||||||
fromJS,
|
fromJS,
|
||||||
} from 'immutable';
|
} from 'immutable';
|
||||||
|
|
||||||
|
import { normalizeAttachment } from 'soapbox/normalizers/attachment';
|
||||||
|
|
||||||
import type { Attachment, Card, Emoji } from 'soapbox/types/entities';
|
import type { Attachment, Card, Emoji } from 'soapbox/types/entities';
|
||||||
|
|
||||||
export const ChatMessageRecord = ImmutableRecord({
|
export const ChatMessageRecord = ImmutableRecord({
|
||||||
|
@ -22,8 +24,14 @@ export const ChatMessageRecord = ImmutableRecord({
|
||||||
pending: false,
|
pending: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const normalizeMedia = (status: ImmutableMap<string, any>) => {
|
||||||
|
return status.update('attachment', null, normalizeAttachment);
|
||||||
|
};
|
||||||
|
|
||||||
export const normalizeChatMessage = (chatMessage: Record<string, any>) => {
|
export const normalizeChatMessage = (chatMessage: Record<string, any>) => {
|
||||||
return ChatMessageRecord(
|
return ChatMessageRecord(
|
||||||
ImmutableMap(fromJS(chatMessage)),
|
ImmutableMap(fromJS(chatMessage)).withMutations(chatMessage => {
|
||||||
|
normalizeMedia(chatMessage);
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue