From 6971466c397b1339367d536e451ec1ae0139cb37 Mon Sep 17 00:00:00 2001 From: Juan Carlos Ruvalcaba Date: Sun, 25 Apr 2021 15:20:30 -0700 Subject: [PATCH] Replace object to string on change theme --- src/app.f7.html | 3 +-- src/js/stores/theme.js | 8 +++++--- src/pages/home/panel-left.f7.html | 3 +-- src/pages/home/panel-right.f7.html | 3 +-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/app.f7.html b/src/app.f7.html index 2de82b7..20032fb 100644 --- a/src/app.f7.html +++ b/src/app.f7.html @@ -13,8 +13,7 @@ import themes from './js/stores/theme.js'; export default (props, { $f7, $, $update, $onMounted }) => { $onMounted(async () => { - const selector = '#app'; - await themes.dispatch('initTheme', { selector }); + await themes.dispatch('initTheme', '#app'); }); return $render; diff --git a/src/js/stores/theme.js b/src/js/stores/theme.js index 786d21a..4ad9e13 100644 --- a/src/js/stores/theme.js +++ b/src/js/stores/theme.js @@ -7,18 +7,20 @@ const theme = createStore({ name: 'theme-dark', }, actions: { +//Mutations changeTheme({ state }, name) { state.name = name; }, - async checkTheme({ state, dispatch }, { selector }){ +//End mutations + async checkTheme({ state, dispatch }, selector){ let theme = await localForage.getItem('theme'); if (theme != 'theme-dark'){ $(selector).removeClass('theme-dark'); } dispatch('changeTheme', theme); }, - async initTheme({state, dispatch}, { selector }){ + async initTheme({state, dispatch}, selector){ let items = await localForage.length(); if (items > 0){ - await dispatch('checkTheme', { selector }); + await dispatch('checkTheme', selector); } }, async setTheme({ state, dispatch }, name){ diff --git a/src/pages/home/panel-left.f7.html b/src/pages/home/panel-left.f7.html index 4a50f17..b42b545 100644 --- a/src/pages/home/panel-left.f7.html +++ b/src/pages/home/panel-left.f7.html @@ -140,8 +140,7 @@ export default (props, { $f7, $, $onMounted, $update, }) => { }; $onMounted(async () => { - const selector = '.panel-left'; - await themes.dispatch('checkTheme', { selector }); + await themes.dispatch('checkTheme', '.panel-left'); if (isLogged){ isCustomer = userRoles.includes(4); //Customer, diff --git a/src/pages/home/panel-right.f7.html b/src/pages/home/panel-right.f7.html index 705d997..2d931b8 100644 --- a/src/pages/home/panel-right.f7.html +++ b/src/pages/home/panel-right.f7.html @@ -74,8 +74,7 @@ export default (props, { $f7, $, $on, $onMounted, $update, $f7router }) => { $onMounted(async () => { $('#light-theme').prop('checked', (theme != 'theme-dark') ? true : false ); - const selector = '.panel-right' - await themes.dispatch('checkTheme', { selector }); + await themes.dispatch('checkTheme', '.panel-right'); }); const logout = () => {