Safeguarding against empty default profile

This commit is contained in:
Magnus Åhall 2026-07-18 09:23:00 +02:00
parent da8256f002
commit af11eb9010
2 changed files with 12 additions and 1 deletions

View file

@ -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.')