-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;
$onMounted(() => {
localForage.getItem('theme').then( (value) => {
theme = value;
if (value != 'theme-dark'){ $("#app").removeClass("theme-dark"); }
$onMounted(async () => {
const items = await localForage.length();
if (items > 0){
theme = await localForage.getItem('theme');
if (theme != 'theme-dark'){ $("#app").removeClass("theme-dark"); }
themes.dispatch('changeTheme', theme);
});
}
});
return $render;

View File

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

View File

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