Fix broken theme switcher

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2023-06-10 20:50:53 +02:00
parent f89b17d46b
commit 6657c7f712
Signed by: luzifer
GPG key ID: D91C3E91E4CAD6F5

View file

@ -215,23 +215,6 @@ const passwordCharset = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRS
const passwordLength = 20 const passwordLength = 20
export default { export default {
name: 'App',
data() {
return {
customize: {},
error: '',
explanationShown: false,
mode: 'create',
secret: '',
securePassword: '',
secretId: '',
secretQRDataURL: '',
showError: false,
darkTheme: false,
}
},
computed: { computed: {
secretUrl() { secretUrl() {
return [ return [
@ -244,18 +227,19 @@ export default {
}, },
}, },
watch: { data() {
darkTheme(to) { return {
window.setTheme(to ? 'dark' : 'light') customize: {},
}, darkTheme: false,
}, error: '',
explanationShown: false,
// Trigger initialization functions mode: 'create',
mounted() { secret: '',
this.customize = window.OTSCustomize secretId: '',
this.darkTheme = window.getTheme() === 'dark' secretQRDataURL: '',
window.onhashchange = this.hashLoad securePassword: '',
this.hashLoad() showError: false,
}
}, },
methods: { methods: {
@ -354,16 +338,29 @@ export default {
} }
}) })
}, },
}, },
// Trigger initialization functions
mounted() {
this.customize = window.OTSCustomize
this.darkTheme = window.getTheme() === 'dark'
window.onhashchange = this.hashLoad
this.hashLoad()
},
name: 'App',
watch: { watch: {
darkTheme(to) {
window.setTheme(to ? 'dark' : 'light')
},
secretUrl(to) { secretUrl(to) {
if (this.customize.disableQRSupport) { if (this.customize.disableQRSupport) {
return return
} }
qrcode.toDataURL(this.secretUrl, { width: 200 }) qrcode.toDataURL(to, { width: 200 })
.then(url => { .then(url => {
this.secretQRDataURL = url this.secretQRDataURL = url
}) })