aboutsummaryrefslogtreecommitdiff
path: root/src/components/status_popover/status_popover.js
diff options
context:
space:
mode:
authortaehoon <th.dev91@gmail.com>2019-10-24 16:53:36 -0400
committertaehoon <th.dev91@gmail.com>2019-10-24 16:53:36 -0400
commit62b2648a3e124ac34d960219b925a6c3569e2229 (patch)
treeb74690cf5b8c255fdd29ed868865449e6d8d1d05 /src/components/status_popover/status_popover.js
parent54a26be90c4e0f770d49fbaa35ae62afd85912bc (diff)
split status preview popover into a separate component
Diffstat (limited to 'src/components/status_popover/status_popover.js')
-rw-r--r--src/components/status_popover/status_popover.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/components/status_popover/status_popover.js b/src/components/status_popover/status_popover.js
new file mode 100644
index 00000000..91b64f72
--- /dev/null
+++ b/src/components/status_popover/status_popover.js
@@ -0,0 +1,43 @@
+import { find } from 'lodash'
+
+const StatusPopover = {
+ name: 'StatusPopover',
+ props: [
+ 'statusId'
+ ],
+ data () {
+ return {
+ preview: null,
+ popperOptions: {
+ modifiers: {
+ preventOverflow: { padding: { top: 50 }, boundariesElement: 'viewport' }
+ }
+ }
+ }
+ },
+ components: {
+ Status: () => import('../status/status.vue')
+ },
+ methods: {
+ enter () {
+ const id = this.statusId
+ const statuses = this.$store.state.statuses.allStatuses
+
+ if (!this.preview) {
+ // 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')
+ }
+ }
+ }
+}
+
+export default StatusPopover