Skip to content

Commit

Permalink
add media check
Browse files Browse the repository at this point in the history
  • Loading branch information
vikdiesel committed Nov 27, 2021
1 parent e63fb3d commit 2a3799f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ store.dispatch('fetch', 'clients')
store.dispatch('fetch', 'history')

/* Dark mode */
if (localStorage.getItem(darkModeKey)) {
const localStorageDarkModeValue = localStorage.getItem(darkModeKey)

if ((localStorageDarkModeValue === null && window.matchMedia('(prefers-color-scheme: dark)').matches) || localStorageDarkModeValue === '1') {
store.dispatch('darkMode')
}

Expand Down
6 changes: 1 addition & 5 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,7 @@ export default createStore({

document.documentElement.classList[value ? 'add' : 'remove']('dark')

if (value) {
localStorage.setItem(darkModeKey, '1')
} else {
localStorage.removeItem(darkModeKey)
}
localStorage.setItem(darkModeKey, value ? '1' : '0')

commit('basic', {
key: 'darkMode',
Expand Down

0 comments on commit 2a3799f

Please sign in to comment.