1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-22 05:19:22 +00:00

Avoid a lot of database requests

This commit is contained in:
Pierre HUBERT 2020-04-02 10:59:00 +02:00
parent 25f25815f5
commit 969c644aad

View File

@ -163,7 +163,7 @@ export class CommentsController {
// Check if we have to load like information // Check if we have to load like information
if(!assumeNoLike) { if(!assumeNoLike) {
data.likes = await LikesHelper.Count(c.id, LikesType.COMMENT); 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; return data;