Kaynağa Gözat

Remove event handling for heart button

sbkwgh 8 yıl önce
ebeveyn
işleme
d6ce215082
2 değiştirilmiş dosya ile 1 ekleme ve 24 silme
  1. 1 12
      src/components/ThreadPost.vue
  2. 0 12
      src/components/routes/Thread.vue

+ 1 - 12
src/components/ThreadPost.vue

@@ -31,12 +31,7 @@
 				class='post__footer_group'
 			>
 				<div class='post__footer_sub_group'>
-					<heart-button
-						:liked='liked'
-						:likes='post.Likes'
-						:likeable='$store.state.username && $store.state.username !== username'
-						@change='emitLikeUpdate'
-					></heart-button>
+					<heart-button :post='post'></heart-button>
 				</div>
 				<div class='post__footer_sub_group' v-if='post.Replies.length'>
 					<span class='post__footer_sub_group__text post__footer_sub_group__text--replies'>replies</span>
@@ -102,9 +97,6 @@
 				} else {
 					return '[deleted]'
 				}
-			},
-			liked () {
-				return this.post.Likes.some(u => u.username === this.$store.state.username)
 			}
 		},
 		methods: {
@@ -116,9 +108,6 @@
 			},
 			goToThread () {
 				this.$router.push(`/thread/${this.post.Thread.slug}/${this.post.Thread.id}`)
-			},
-			emitLikeUpdate (state) {
-				this.$emit('like', this.post.id, state)
 			}
 		}
 	}

+ 0 - 12
src/components/routes/Thread.vue

@@ -37,7 +37,6 @@
 					v-for='(post, index) in posts'
 					@reply='replyUser'
 					@goToPost='goToPost'
-					@like='updatePostLike'
 					:post='post'
 					:show-reply='true'
 					:highlight='highlightedPostIndex === index'
@@ -125,17 +124,6 @@
 			addPost () {
 				this.$store.dispatch('addPostAsync', this);
 			},
-			updatePostLike (id, state) {
-				if(state) {
-					this.axios
-						.put('/api/v1/post/' + id + '/like')
-						.catch(AjaxErrorHandler(this.$store))
-				} else {
-					this.axios
-						.delete('/api/v1/post/' + id + '/like')
-						.catch(AjaxErrorHandler(this.$store))
-				}
-			},
 			loadNextPosts () {
 				let vue = this
 				this.$store.dispatch('loadPostsAsync', { vue, previous: false });