Merge branch 'video-meta' into 'develop'

Ensure attachment meta is not null

See merge request soapbox-pub/soapbox-fe!1619
This commit is contained in:
marcin mikołajczak 2022-07-09 07:21:49 +00:00
commit 59cc913083

View file

@ -46,8 +46,18 @@ const normalizeUrls = (attachment: ImmutableMap<string, any>) => {
return attachment.mergeWith(mergeDefined, base);
};
// Ensure meta is not null
const normalizeMeta = (attachment: ImmutableMap<string, any>) => {
const meta = ImmutableMap().merge(attachment.get('meta'));
return attachment.set('meta', meta);
};
export const normalizeAttachment = (attachment: Record<string, any>) => {
return AttachmentRecord(
normalizeUrls(ImmutableMap(fromJS(attachment))),
ImmutableMap(fromJS(attachment)).withMutations((attachment: ImmutableMap<string, any>) => {
normalizeUrls(attachment);
normalizeMeta(attachment);
}),
);
};