Small cleanup

This commit is contained in:
Magnus Åhall 2026-06-22 09:07:04 +02:00
parent 74851b9c4d
commit c8308664d3
2 changed files with 5 additions and 4 deletions

View file

@ -66,7 +66,6 @@ export class App {
_mbus.subscribe('DEVICE_PREFERENCE_SET_UPDATED', ()=>{ _mbus.subscribe('DEVICE_PREFERENCE_SET_UPDATED', ()=>{
this.preferences = this.getPreferences() this.preferences = this.getPreferences()
console.log(this.preferences.data)
}) })
window.addEventListener('keydown', event => this.keyHandler(event)) window.addEventListener('keydown', event => this.keyHandler(event))

View file

@ -45,7 +45,7 @@ export class N2PagePreferences extends CustomHTMLElement {
this.elNewSet.addEventListener('click', () => this.newSet()) this.elNewSet.addEventListener('click', () => this.newSet())
this.elSave.addEventListener('click', () => this.save()) this.elSave.addEventListener('click', () => this.save())
this.elDevPreferenceSet.addEventListener('change', event=>this.changePreferenceSet(event)) this.elDevPreferenceSet.addEventListener('change', ()=>this.changePreferenceSet())
window._mbus.subscribe('SHOW_PAGE', async event => { window._mbus.subscribe('SHOW_PAGE', async event => {
if (event.detail.data?.page == 'preferences') { if (event.detail.data?.page == 'preferences') {
@ -71,7 +71,7 @@ export class N2PagePreferences extends CustomHTMLElement {
this.sets.sort(this.sortSets) this.sets.sort(this.sortSets)
this.elSets.replaceChildren(...this.sets) this.elSets.replaceChildren(...this.sets)
const setNames = this.sets.entries().map(([i, set]) => { const setNames = this.sets.entries().map(([_idx, set]) => {
const optn = document.createElement('option') const optn = document.createElement('option')
optn.innerText = set.name optn.innerText = set.name
return optn return optn
@ -106,7 +106,7 @@ export class N2PagePreferences extends CustomHTMLElement {
alert(`Error retrieving preferences: ${e.message}`) alert(`Error retrieving preferences: ${e.message}`)
} }
}// }}} }// }}}
changePreferenceSet(event) {// {{{ changePreferenceSet() {// {{{
this.preferencesModified() this.preferencesModified()
}// }}} }// }}}
newSet() {// {{{ newSet() {// {{{
@ -168,6 +168,8 @@ export class N2PagePreferences extends CustomHTMLElement {
user.Preferences = newPrefs user.Preferences = newPrefs
localStorage.setItem('user', JSON.stringify(user)) localStorage.setItem('user', JSON.stringify(user))
localStorage.setItem('device_preference_set', this.elDevPreferenceSet.value) localStorage.setItem('device_preference_set', this.elDevPreferenceSet.value)
// Application is told that reloading preferences is to be done.
_mbus.dispatch('DEVICE_PREFERENCE_SET_UPDATED') _mbus.dispatch('DEVICE_PREFERENCE_SET_UPDATED')
} catch (e) { } catch (e) {
console.error(e) console.error(e)