-Min refactor

-Fix unauth access -not tested
-Fix initial them setting
This commit is contained in:
Juan Carlos Ruvalcaba 2021-04-24 17:26:44 -07:00
parent a3bef880a0
commit 68d3b0fcc3
3 changed files with 13 additions and 9 deletions

View File

@ -15,12 +15,13 @@ export default (props, { $f7, $, $update, $onMounted }) => {
let theme = themes.getters.Name.value; let theme = themes.getters.Name.value;
$onMounted(() => { $onMounted(async () => {
localForage.getItem('theme').then( (value) => { const items = await localForage.length();
theme = value; if (items > 0){
if (value != 'theme-dark'){ $("#app").removeClass("theme-dark"); } theme = await localForage.getItem('theme');
if (theme != 'theme-dark'){ $("#app").removeClass("theme-dark"); }
themes.dispatch('changeTheme', theme); themes.dispatch('changeTheme', theme);
}); }
}); });
return $render; return $render;

View File

@ -19,6 +19,9 @@ import http from './api/config.js';
// Import main app component // Import main app component
import App from '../app.f7.html'; import App from '../app.f7.html';
// Import user store
import user from './stores/user.js';
var device = getDevice(); var device = getDevice();
var app = new Framework7({ var app = new Framework7({
name: 'Comida Cab', // App name name: 'Comida Cab', // App name
@ -69,7 +72,7 @@ var app = new Framework7({
http.interceptors.response.use(undefined, function (err) { http.interceptors.response.use(undefined, function (err) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
if (err.status === 401 && err.config && !err.config.__isRetryRequest) { if (err.status === 401 && err.config && !err.config.__isRetryRequest) {
//user.dispatch('logout'); //To fix user.dispatch('logOut').then( () => { } ); //Untested
} }
throw err; throw err;
}); });

View File

@ -32,8 +32,8 @@ const user = createStore({
logOut({ state, dispatch }){ logOut({ state, dispatch }){
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
dispatch('logout'); dispatch('logout');
localStorage.removeItem('token') localStorage.removeItem('token');
http.defaults.headers.common['Authorization']; delete http.defaults.headers.common['Authorization'];
resolve(); resolve();
}); });
}, },