Safeguarding against empty default profile
This commit is contained in:
parent
da8256f002
commit
af11eb9010
2 changed files with 12 additions and 1 deletions
|
|
@ -238,6 +238,7 @@ export class N2PreferenceSet extends CustomHTMLElement {
|
|||
super(true)
|
||||
this.name = name
|
||||
this.data = data
|
||||
this.validateDefaultProfile()
|
||||
this.render()
|
||||
|
||||
// Enable the save button when settings are modified.
|
||||
|
|
@ -248,6 +249,16 @@ export class N2PreferenceSet extends CustomHTMLElement {
|
|||
this.elName.addEventListener('click', () => this.updateName())
|
||||
this.elDelete.addEventListener('click', () => this.deleteSet())
|
||||
}// }}}
|
||||
validateDefaultProfile() {// {{{
|
||||
if (!this.data.hasOwnProperty('default'))
|
||||
this.data.default = {}
|
||||
|
||||
if (!this.data.default.hasOwnProperty('DownloadFiles'))
|
||||
this.data.default.DownloadFiles = false
|
||||
|
||||
if (!this.data.default.hasOwnProperty('DownloadImages'))
|
||||
this.data.default.DownloadImages = false
|
||||
}// }}}
|
||||
updateName() {// {{{
|
||||
if (this.name == 'default') {
|
||||
alert('Can not change name of the default profile.')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue