refactor: event delegation, unified subscription cleanup, centralized listing status helpers
This commit is contained in:
@@ -23,23 +23,24 @@ class PageSettings extends HTMLElement {
|
||||
this.render()
|
||||
this.setupEventListeners()
|
||||
|
||||
this.unsubscribe = i18n.subscribe(() => {
|
||||
this._unsubs = []
|
||||
this._unsubs.push(i18n.subscribe(() => {
|
||||
this.render()
|
||||
this.setupEventListeners()
|
||||
})
|
||||
}))
|
||||
|
||||
this.authUnsubscribe = auth.subscribe(() => {
|
||||
this._unsubs.push(auth.subscribe(() => {
|
||||
this.isLoggedIn = auth.isLoggedIn()
|
||||
|
||||
if (!this.isLoggedIn) {
|
||||
window.location.hash = '#/'
|
||||
}
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
disconnectedCallback() {
|
||||
if (this.unsubscribe) this.unsubscribe()
|
||||
if (this.authUnsubscribe) this.authUnsubscribe()
|
||||
this._unsubs.forEach(fn => fn())
|
||||
this._unsubs = []
|
||||
}
|
||||
|
||||
setupEventListeners() {
|
||||
|
||||
Reference in New Issue
Block a user