Small refactor for user preferences

This commit is contained in:
Magnus Åhall 2026-06-18 09:21:23 +02:00
parent 1a712fb7a9
commit 81d02b82dc
13 changed files with 202 additions and 112 deletions

View file

@ -0,0 +1,32 @@
import { CustomHTMLElement } from "./lib/custom_html_element.mjs"
import { API } from './api.mjs'
export class N2PagePreferences extends CustomHTMLElement {
static {// {{{
this.tmpl = document.createElement('template')
this.tmpl.innerHTML = `
<h1>Preferences</h1>
`
}// }}}
constructor() {// {{{
super()
window._mbus.subscribe('SHOW_PAGE', event => {
if (event.detail.data?.page == 'preferences')
this.render()
})
}// }}}
async render() {// {{{
}// }}}
getPreferences() {
API.query('GET', '/user/preferences')
}
}
customElements.define('n2-pagepreferences', N2PagePreferences)
// Preferences is a set of preferences, of which there can be many named.
class Preferences {
constructor(name, data) {
this.name = name
this.data = data
}
}