Explorar o código

Use ajax for reply name

sbkwgh %!s(int64=8) %!d(string=hai) anos
pai
achega
695dfbce67
Modificáronse 2 ficheiros con 14 adicións e 2 borrados
  1. 1 0
      src/components/InfoTooltip.vue
  2. 13 2
      src/components/ReplyingTo.vue

+ 1 - 0
src/components/InfoTooltip.vue

@@ -38,6 +38,7 @@
 				if(val) {
 					this.pointerEvents = true
 					this.show = true
+					this.$emit('hover')
 				} else {
 					this.show = false;
 					setTimeout(() => {

+ 13 - 2
src/components/ReplyingTo.vue

@@ -1,5 +1,5 @@
 <template>
-	<info-tooltip class='replying_to'>
+	<info-tooltip class='replying_to' @hover='loadPost'>
 		<template slot='content'>
 			<div style='margin-top: -0.25rem;'>
 				<div class='replying_to__username' v-if='post'>{{post.User.username}}</div>
@@ -25,12 +25,23 @@
 	export default {
 		name: 'ReplyingTo',
 		props: ['replyId', 'username'],
+		components: { InfoTooltip },
 		data () {
 			return {
 				post: null
 			}
 		},
-		components: { InfoTooltip }
+		methods: {
+			loadPost () {
+				if(this.post) return
+
+				this.axios
+					.get('/api/v1/post/' + this.replyId)
+					.then((res) => {
+						this.post = res.data
+					})
+			}
+		}
 	}
 </script>