Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix: strip unsupported props from db wallet entries
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed May 3, 2020
1 parent 9053134 commit d058956
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions renderer/store/schema/wallet.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import decode from 'lndconnect/decode'
import Dexie from 'dexie'
import set from 'lodash/set'
import get from 'lodash/get'

const getlndConnectProp = (lndconnectUri, prop) => {
const data = decode(lndconnectUri)
Expand Down Expand Up @@ -96,15 +97,14 @@ export const hooks = {
return Object.keys({ ...obj, ...modifications }).reduce((acc, cur) => {
const [rootKey] = cur.split('.')
const isValidKey = Object.keys(Wallet.SCHEMA).includes(rootKey)

if (isValidKey) {
const isInMods = Object.keys(modifications).includes(cur)
const newVal = isInMods ? modifications[cur] : Dexie.getByKeyPath(obj, cur)
Dexie.setByKeyPath(acc, cur, newVal)
const newVal = isInMods ? modifications[cur] : get(obj, cur)
set(acc, cur, newVal)
} else {
// if key is not in the whitelist set it to undefined
// so it's later merged with the db object
Dexie.setByKeyPath(acc, cur, undefined)
set(acc, cur, undefined)
}
return acc
}, {})
Expand Down

0 comments on commit d058956

Please sign in to comment.