Fix problem with missing loginData

This commit is contained in:
Peter Stuifzand 2018-08-29 16:02:49 +02:00
parent 31ae5c7e65
commit 6d8e657fc5
4 changed files with 13 additions and 6 deletions

View File

@ -14,3 +14,4 @@ Some features that need to be implemented
- Better responsive interface
- Websockets? Show new channels and new items in channels directly, needs
micropub server support
- Improve handling of entries with missing values (like missing author)

View File

@ -31,8 +31,11 @@
name: 'App',
components: {LoginModal},
mounted() {
let loginData = JSON.parse(window.localStorage.getItem('login_data'))
this.$store.dispatch('isLoggedIn', loginData)
let item = window.localStorage.getItem('login_data');
if (item) {
let loginData = JSON.parse(item)
this.$store.dispatch('isLoggedIn', loginData)
}
}
}
</script>

View File

@ -84,7 +84,7 @@
}).then(response => response.json())
.then(response => {
this.$store.dispatch('tokenResponse', response)
this.active = false
this.show = false
this.$router.push('/')
})
}

View File

@ -8,14 +8,17 @@ Vue.use(Vuex)
export default new Vuex.Store({
state() {
let loginData = JSON.parse(window.localStorage.getItem('login_data'))
return {
...loginData,
let newState = {
channels: [],
timeline: {items: [], paging: {}},
channel: {},
debug: false,
logged_in: loginData.access_token && loginData.access_token.length > 0
};
if (loginData) {
newState = { ...newState, ...loginData }
newState.logged_in = loginData.access_token && loginData.access_token.length > 0
}
return newState
},
mutations: {