Add back old hack because it's still needed

This commit is contained in:
root
2022-08-26 04:24:25 +05:30
parent 0a4ba3c63f
commit 83382109d2
+22 -1
View File
@@ -1,6 +1,9 @@
import Vue from 'vue'
import Vuetify from 'vuetify/lib/framework'
import { isString } from 'lodash-es'
import { COLOR_SCHEME_STATES } from '@/store/prefs-store'
Vue.use(Vuetify)
export default new Vuetify({
@@ -9,7 +12,25 @@ export default new Vuetify({
},
theme: {
// There's apparently a race condition that causes components being rendered shortly before dark mode initialization unable to change to dark mode
dark: false,
dark: (() => {
// Partly duplicated in App.vue
try {
const LSValue = window.localStorage.getItem('COLOR_SCHEME')
if (isString(LSValue) && LSValue.length !== 0) {
const state = JSON.parse(LSValue)
switch (state) {
case COLOR_SCHEME_STATES.SYSTEM:
return window.matchMedia('(prefers-color-scheme: dark)').matches
case COLOR_SCHEME_STATES.DARK:
return true
case COLOR_SCHEME_STATES.LIGHT:
return false
}
}
} catch (e) {
return false
}
})(),
themes: {
light: {
primary: '#455A64',