Ensure attachment meta is not null

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
environments/review-develop-3zknud/deployments/513^2
marcin mikołajczak 2022-07-09 00:15:26 +02:00
rodzic 79b11fefde
commit 8be4bb7409
1 zmienionych plików z 11 dodań i 1 usunięć

Wyświetl plik

@ -46,8 +46,18 @@ const normalizeUrls = (attachment: ImmutableMap<string, any>) => {
return attachment.mergeWith(mergeDefined, base); 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>) => { export const normalizeAttachment = (attachment: Record<string, any>) => {
return AttachmentRecord( return AttachmentRecord(
normalizeUrls(ImmutableMap(fromJS(attachment))), ImmutableMap(fromJS(attachment)).withMutations((attachment: ImmutableMap<string, any>) => {
normalizeUrls(attachment);
normalizeMeta(attachment);
}),
); );
}; };