瀏覽代碼

Update LikeService, show like count to status owner

Daniel Supernault 4 年之前
父節點
當前提交
4408e2ef8c
共有 2 個文件被更改,包括 9 次插入2 次删除
  1. 8 1
      app/Services/LikeService.php
  2. 1 1
      resources/assets/js/components/Timeline.vue

+ 8 - 1
app/Services/LikeService.php

@@ -71,9 +71,16 @@ class LikeService {
 
 		$id = $like->profile_id;
 
-		return [
+		$res = [
 			'username' => ProfileService::get($id)['username'],
 			'others' => $status->likes_count >= 5,
 		];
+
+		if(request()->user()->profile_id == $status->profile_id) {
+			$res['total_count'] = $status->likes_count;
+			$res['total_count_pretty'] = number_format($res['total_count']);
+		}
+
+		return $res;
 	}
 }

+ 1 - 1
resources/assets/js/components/Timeline.vue

@@ -228,7 +228,7 @@
 									<span class="like-count">Liked by
 										<a class="font-weight-bold text-dark" :href="'/'+status.liked_by.username">{{status.liked_by.username}}</a>
 										<span v-if="status.liked_by.others == true">
-											and <span class="font-weight-bold">others</span>
+											and <span class="font-weight-bold" v-if="status.liked_by.total_count_pretty">{{status.liked_by.total_count_pretty}}</span> <span class="font-weight-bold">others</span>
 										</span>
 									</span>
 								</div>