From 969c644aad421fced854c6ae68cca1d2ff94cf10 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 2 Apr 2020 10:59:00 +0200 Subject: [PATCH] Avoid a lot of database requests --- src/controllers/CommentsController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/CommentsController.ts b/src/controllers/CommentsController.ts index 0706b9a..1b53fac 100644 --- a/src/controllers/CommentsController.ts +++ b/src/controllers/CommentsController.ts @@ -163,7 +163,7 @@ export class CommentsController { // Check if we have to load like information if(!assumeNoLike) { data.likes = await LikesHelper.Count(c.id, LikesType.COMMENT); - data.userlike = h.signedIn ? await LikesHelper.IsLiking(h.getUserId(), c.id, LikesType.COMMENT) : false; + data.userlike = data.likes > 0 && h.signedIn ? await LikesHelper.IsLiking(h.getUserId(), c.id, LikesType.COMMENT) : false; } return data;