Fix problem with missing loginData
This commit is contained in:
parent
31ae5c7e65
commit
6d8e657fc5
1
TODO.txt
1
TODO.txt
|
|
@ -14,3 +14,4 @@ Some features that need to be implemented
|
||||||
- Better responsive interface
|
- Better responsive interface
|
||||||
- Websockets? Show new channels and new items in channels directly, needs
|
- Websockets? Show new channels and new items in channels directly, needs
|
||||||
micropub server support
|
micropub server support
|
||||||
|
- Improve handling of entries with missing values (like missing author)
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,11 @@
|
||||||
name: 'App',
|
name: 'App',
|
||||||
components: {LoginModal},
|
components: {LoginModal},
|
||||||
mounted() {
|
mounted() {
|
||||||
let loginData = JSON.parse(window.localStorage.getItem('login_data'))
|
let item = window.localStorage.getItem('login_data');
|
||||||
this.$store.dispatch('isLoggedIn', loginData)
|
if (item) {
|
||||||
|
let loginData = JSON.parse(item)
|
||||||
|
this.$store.dispatch('isLoggedIn', loginData)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@
|
||||||
}).then(response => response.json())
|
}).then(response => response.json())
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.$store.dispatch('tokenResponse', response)
|
this.$store.dispatch('tokenResponse', response)
|
||||||
this.active = false
|
this.show = false
|
||||||
this.$router.push('/')
|
this.$router.push('/')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,17 @@ Vue.use(Vuex)
|
||||||
export default new Vuex.Store({
|
export default new Vuex.Store({
|
||||||
state() {
|
state() {
|
||||||
let loginData = JSON.parse(window.localStorage.getItem('login_data'))
|
let loginData = JSON.parse(window.localStorage.getItem('login_data'))
|
||||||
return {
|
let newState = {
|
||||||
...loginData,
|
|
||||||
channels: [],
|
channels: [],
|
||||||
timeline: {items: [], paging: {}},
|
timeline: {items: [], paging: {}},
|
||||||
channel: {},
|
channel: {},
|
||||||
debug: false,
|
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: {
|
mutations: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user