Browse Source

Make reply bar dynamic

sbkwgh 8 năm trước cách đây
mục cha
commit
a0324ccbda
1 tập tin đã thay đổi với 18 bổ sung5 xóa
  1. 18 5
      src/components/ThreadDisplay.vue

+ 18 - 5
src/components/ThreadDisplay.vue

@@ -22,13 +22,18 @@
 				</div>
 			</div>
 			<div class='thread_display__replies_bar' @click.self='goToThread'>
-				<div class='thread_display__latest_reply'>
+				<div
+					class='thread_display__latest_reply'
+					v-if='thread.Posts.length === 2'
+					@click='goToPost'
+				>
 					<span class='fa fa-reply fa-fw'></span>
 					Latest reply by
-					<span class='thread_display__username'>username</span>
+					<span class='thread_display__username'>{{thread.Posts[1].User.username}}</span>
 					&middot;
-					<span class='thread_display__date'>just now</span>
+					<span class='thread_display__date'>{{thread.Posts[1].createdAt | formatDate}}</span>
 				</div>
+				<span style='cursor: default;' v-else>No replies</span>
 				<div class='thread_display__replies' title='Replies to thread' @click='goToThread'>
 					<span class='fa fa-comment-o fa-fw'></span>
 					{{thread.postsCount - 1}}
@@ -54,11 +59,19 @@
 			goToUser () {
 				this.$router.push('/user/' + this.thread.User.username)
 			},
-			goToThread (e) {
+			goToThread () {
 				this.$router.push('/thread/' + this.thread.slug + '/' + this.thread.id)
 			},
-			goToCategory (e) {
+			goToCategory () {
 				this.$router.push('/category/' + this.thread.Category.value.toLowerCase())
+			},
+			goToPost () {
+				this.$router.push(
+					'/thread/' +
+					this.thread.slug + '/' +
+					this.thread.id + '/' +
+					this.thread.Posts[1].postNumber
+				)
 			}
 		}
 	}