parseAndWriteAvatar: Do shallow copy before omit() call
Otherwise, we get all prototype props/functions, which we can't save in IndexedDB
This commit is contained in:
parent
3bf8a8966a
commit
d2293d9592
1 changed files with 6 additions and 2 deletions
|
@ -14,14 +14,18 @@ exports.parseAndWriteAvatar = upgradeAttachment => async (
|
|||
) => {
|
||||
const { message } = context;
|
||||
const { avatar } = contact;
|
||||
|
||||
// This is to ensure that an omit() call doesn't pull in prototype props/methods
|
||||
const contactShallowCopy = Object.assign({}, contact);
|
||||
|
||||
const contactWithUpdatedAvatar =
|
||||
avatar && avatar.avatar
|
||||
? Object.assign({}, contact, {
|
||||
? Object.assign({}, contactShallowCopy, {
|
||||
avatar: Object.assign({}, avatar, {
|
||||
avatar: await upgradeAttachment(avatar.avatar, context),
|
||||
}),
|
||||
})
|
||||
: omit(contact, ['avatar']);
|
||||
: omit(contactShallowCopy, ['avatar']);
|
||||
|
||||
// eliminates empty numbers, emails, and addresses; adds type if not provided
|
||||
const parsedContact = parseContact(contactWithUpdatedAvatar);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue