Ensure attachment meta is not null
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
79b11fefde
commit
8be4bb7409
1 changed files with 11 additions and 1 deletions
|
@ -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);
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue