Move auth type checks to computed properties
This commit is contained in:
parent
8dd6ce4a86
commit
7ed7d1ece2
27
src/App.vue
27
src/App.vue
|
@ -3,9 +3,9 @@
|
|||
<template v-if="online">
|
||||
<!-- This is a workaround to get the sw to "see" the to-be-cached version of the offline background image -->
|
||||
<div class="offline" style="height: 0;width: 0;"></div>
|
||||
<top-navigation v-if="userAuthenticated && (userInfo && userInfo.type === authTypes.USER)"/>
|
||||
<content-auth v-if="userAuthenticated && (userInfo && userInfo.type === authTypes.USER)"/>
|
||||
<content-link-share v-else-if="userAuthenticated && (userInfo && userInfo.type === authTypes.LINK_SHARE)"/>
|
||||
<top-navigation v-if="authUser"/>
|
||||
<content-auth v-if="authUser"/>
|
||||
<content-link-share v-else-if="authLinkShare"/>
|
||||
<content-no-auth v-else/>
|
||||
<notification/>
|
||||
</template>
|
||||
|
@ -49,7 +49,6 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
currentDate: new Date(),
|
||||
authTypes: authTypes,
|
||||
}
|
||||
},
|
||||
beforeMount() {
|
||||
|
@ -123,11 +122,19 @@ export default {
|
|||
}
|
||||
})
|
||||
},
|
||||
computed: mapState({
|
||||
userInfo: state => state.auth.info,
|
||||
userAuthenticated: state => state.auth.authenticated,
|
||||
online: ONLINE,
|
||||
keyboardShortcutsActive: KEYBOARD_SHORTCUTS_ACTIVE,
|
||||
}),
|
||||
computed: {
|
||||
authUser() {
|
||||
return this.userAuthenticated && (this.userInfo && this.userInfo.type === authTypes.USER)
|
||||
},
|
||||
authLinkShare() {
|
||||
return this.userAuthenticated && (this.userInfo && this.userInfo.type === authTypes.LINK_SHARE)
|
||||
},
|
||||
...mapState({
|
||||
userInfo: state => state.auth.info,
|
||||
userAuthenticated: state => state.auth.authenticated,
|
||||
online: ONLINE,
|
||||
keyboardShortcutsActive: KEYBOARD_SHORTCUTS_ACTIVE,
|
||||
}),
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
Reference in New Issue