traxxx/assets/js/ui/observers.js

37 lines
752 B
JavaScript
Raw Permalink Normal View History

2021-04-22 17:44:23 +00:00
async function initUiObservers(store, _router) {
const body = document.querySelector('body');
body.classList.add(store.state.ui.theme);
2021-11-20 22:59:15 +00:00
store.watch((state) => state.ui.theme, (newTheme, oldTheme) => {
body.classList.add(newTheme);
body.classList.remove(oldTheme);
});
document.addEventListener('keypress', (event) => {
if (event.target.tagName === 'INPUT') {
return;
}
if (event.key === 's') {
store.dispatch('setSfw', true);
}
if (event.key === 'n') {
store.dispatch('setSfw', false);
}
2020-05-13 00:56:20 +00:00
if (event.key === 'd') {
store.dispatch('setTheme', 'dark');
}
2020-05-13 00:56:20 +00:00
if (event.key === 'l') {
store.dispatch('setTheme', 'light');
}
});
2021-04-22 17:44:23 +00:00
await store.dispatch('fetchNotifications');
}
export default initUiObservers;