akkoma-fe/src/components/status_popover/status_popover.js

45 lines
993 B
JavaScript
Raw Normal View History

import { find } from 'lodash'
import { library } from '@fortawesome/fontawesome-svg-core'
import { faCircleNotch } from '@fortawesome/free-solid-svg-icons'
2021-04-25 10:23:16 +00:00
import { defineAsyncComponent } from 'vue'
library.add(
faCircleNotch
)
const StatusPopover = {
name: 'StatusPopover',
props: [
'statusId'
],
data () {
return {
error: false
}
},
2019-10-25 02:14:53 +00:00
computed: {
status () {
return find(this.$store.state.statuses.allStatuses, { id: this.statusId })
}
},
components: {
2021-04-25 10:23:16 +00:00
Status: defineAsyncComponent(() => import('../status/status.vue')),
Popover: defineAsyncComponent(() => import('../popover/popover.vue'))
},
methods: {
enter () {
2019-10-25 02:14:53 +00:00
if (!this.status) {
if (!this.statusId) {
this.error = true
return
}
2019-10-25 02:21:33 +00:00
this.$store.dispatch('fetchStatus', this.statusId)
.then(data => (this.error = false))
.catch(e => (this.error = true))
}
}
}
}
export default StatusPopover