Ensure attachment meta is not null

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2022-07-09 00:15:26 +02:00
parent 79b11fefde
commit 8be4bb7409

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);
}),
);
};