Skip to content

Commit

Permalink
Fixes #1032: ensure when no initial preferences set, that values are …
Browse files Browse the repository at this point in the history
…correctly emptied and removed, before validating on export.
  • Loading branch information
mattRedBox committed Jul 14, 2020
1 parent 1630828 commit e8bfd6c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ipcMain as ipc } from 'electron'

ipc.on('getPreference', (event, arg) => {
const preference = settings.get(arg)
event.returnValue = preference || ''
event.returnValue = preference || []
})

ipc.on('setPreference', (event, name, stringified) => {
Expand Down
15 changes: 9 additions & 6 deletions src/renderer/frictionlessDataPackage.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ function addPackageProperties (descriptor) {
let packageProperties = _.cloneDeep(hotStore.state.packageProperties)
_.merge(descriptor, packageProperties)
removeEmptiesFromDescriptor(descriptor)
removeEmpty(descriptor, 'contributors')
updateCustomsForProperties(descriptor, 'package')
}

Expand Down Expand Up @@ -273,10 +274,12 @@ function addPath (descriptor, tabId) {
function updateCustomsForProperties (descriptor, customType) {
let customs = _.get(descriptor, 'customs', [])
_.unset(descriptor, 'customs')
do {
const custom = customs.pop()
if (!_.isEmpty(_.get(custom, 'name', '')) && !_.isEmpty(_.get(custom, 'value', '')) && _.includes(_.get(custom, 'types', []), customType)) {
_.set(descriptor, custom.name, custom.value)
}
} while (!_.isEmpty(customs))
if (!_.isEmpty(customs)) {
do {
const custom = customs.pop()
if (!_.isEmpty(_.get(custom, 'name', '')) && !_.isEmpty(_.get(custom, 'value', '')) && _.includes(_.get(custom, 'types', []), customType)) {
_.set(descriptor, custom.name, custom.value)
}
} while (!_.isEmpty(customs))
}
}

0 comments on commit e8bfd6c

Please sign in to comment.