refactor status loading logic
This commit is contained in:
parent
62b2648a3e
commit
e00cf288f5
|
@ -7,7 +7,6 @@ const StatusPopover = {
|
||||||
],
|
],
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
preview: null,
|
|
||||||
popperOptions: {
|
popperOptions: {
|
||||||
modifiers: {
|
modifiers: {
|
||||||
preventOverflow: { padding: { top: 50 }, boundariesElement: 'viewport' }
|
preventOverflow: { padding: { top: 50 }, boundariesElement: 'viewport' }
|
||||||
|
@ -15,27 +14,22 @@ const StatusPopover = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
status () {
|
||||||
|
return find(this.$store.state.statuses.allStatuses, { id: this.statusId })
|
||||||
|
}
|
||||||
|
},
|
||||||
components: {
|
components: {
|
||||||
Status: () => import('../status/status.vue')
|
Status: () => import('../status/status.vue')
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
enter () {
|
enter () {
|
||||||
const id = this.statusId
|
if (!this.status) {
|
||||||
const statuses = this.$store.state.statuses.allStatuses
|
this.$store.state.api.backendInteractor.fetchStatus({ id: this.statusId })
|
||||||
|
.then((status) => {
|
||||||
if (!this.preview) {
|
this.$store.dispatch('addNewStatuses', { statuses: [status] })
|
||||||
// if we have the status somewhere already
|
|
||||||
this.preview = find(statuses, { id })
|
|
||||||
// or if we have to fetch it
|
|
||||||
if (!this.preview) {
|
|
||||||
this.$store.state.api.backendInteractor.fetchStatus({ id }).then((status) => {
|
|
||||||
this.preview = status
|
|
||||||
this.$nextTick(this.$refs.popper.updatePopper)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else if (this.preview.id !== id) {
|
|
||||||
this.preview = find(statuses, 'id')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
>
|
>
|
||||||
<div slot="popover">
|
<div slot="popover">
|
||||||
<Status
|
<Status
|
||||||
v-if="preview"
|
v-if="status"
|
||||||
:is-preview="true"
|
:is-preview="true"
|
||||||
:statusoid="preview"
|
:statusoid="status"
|
||||||
:compact="true"
|
:compact="true"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
|
|
Loading…
Reference in New Issue