@@ -107,16 +107,13 @@ function commentsTreeBuildAnonym(comments, usersHash) {
107
107
}
108
108
109
109
// Set latest comment flag.
110
- let latestCommentStamp = 0 ;
111
-
112
110
if ( latestCid ) {
113
111
const latestComment = hash [ latestCid ] ;
114
112
115
113
latestComment . latest = true ;
116
- latestCommentStamp = latestComment . stamp ;
117
114
}
118
115
119
- return { tree, latestCommentStamp } ;
116
+ return { tree, latestCid } ;
120
117
}
121
118
122
119
async function commentsTreeBuildAuth ( { iAm, type, commentModel, obj, canReply, showDel } ) {
@@ -260,13 +257,10 @@ async function commentsTreeBuildAuth({ iAm, type, commentModel, obj, canReply, s
260
257
}
261
258
262
259
// Set latest comment flag.
263
- let latestCommentStamp = 0 ;
264
-
265
260
if ( latestCid ) {
266
261
const latestComment = commentsHash [ latestCid ] ;
267
262
268
263
latestComment . latest = true ;
269
- latestCommentStamp = latestComment . stamp ;
270
264
}
271
265
272
266
const { usersById, usersByLogin } = await getUsersHashForComments ( usersSet ) ;
@@ -312,7 +306,7 @@ async function commentsTreeBuildAuth({ iAm, type, commentModel, obj, canReply, s
312
306
}
313
307
}
314
308
315
- return { tree : commentsTree , users : usersByLogin , countTotal, countNew, countDel, latestCommentStamp } ;
309
+ return { tree : commentsTree , users : usersByLogin , countTotal, countNew, countDel, latestCid } ;
316
310
}
317
311
318
312
async function commentsTreeBuildCanModerate ( { iAm, type, commentModel, obj, showDel } ) {
@@ -413,12 +407,10 @@ async function commentsTreeBuildCanModerate({ iAm, type, commentModel, obj, show
413
407
414
408
// Set latest comment flag.
415
409
const latestComment = commentsMap . get ( latestCid ) ;
416
- let latestCommentStamp = 0 ;
417
410
418
411
if ( latestComment ) {
419
412
latestComment . latest = true ;
420
413
commentsMap . set ( latestCid , latestComment ) ;
421
- latestCommentStamp = latestComment . stamp ;
422
414
}
423
415
424
416
const { usersById, usersByLogin } = await getUsersHashForComments ( usersSet ) ;
@@ -427,7 +419,7 @@ async function commentsTreeBuildCanModerate({ iAm, type, commentModel, obj, show
427
419
comment . user = usersById [ comment . user ] . login ;
428
420
}
429
421
430
- return { tree : commentsTree , users : usersByLogin , countTotal, countNew, countDel, latestCommentStamp } ;
422
+ return { tree : commentsTree , users : usersByLogin , countTotal, countNew, countDel, latestCid } ;
431
423
}
432
424
433
425
async function commentsTreeBuildDel ( comment , childs , checkMyId ) {
@@ -559,14 +551,14 @@ async function getCommentsObjAnonym({ cid, type = 'photo' }) {
559
551
let tree ;
560
552
let usersById ;
561
553
let usersByLogin ;
562
- let latestCommentStamp = 0 ;
554
+ let latestCid = 0 ;
563
555
564
556
if ( usersSet . size ) {
565
557
( { usersById, usersByLogin } = await getUsersHashForComments ( usersSet ) ) ;
566
- ( { tree, latestCommentStamp } = commentsTreeBuildAnonym ( comments , usersById ) ) ;
558
+ ( { tree, latestCid } = commentsTreeBuildAnonym ( comments , usersById ) ) ;
567
559
}
568
560
569
- return { comments : tree || [ ] , countTotal : comments . length , users : usersByLogin , latestCommentStamp } ;
561
+ return { comments : tree || [ ] , countTotal : comments . length , users : usersByLogin , latestCid } ;
570
562
}
571
563
572
564
async function getCommentsObjAuth ( { cid, type = 'photo' , showDel = false } ) {
@@ -590,14 +582,14 @@ async function getCommentsObjAuth({ cid, type = 'photo', showDel = false }) {
590
582
const canModerate = permissions . canModerate ( type , obj , iAm ) ;
591
583
const canReply = permissions . canReply ( type , obj , iAm ) ;
592
584
593
- const { tree, users, countTotal, countNew, countDel, latestCommentStamp } = await ( canModerate ?
585
+ const { tree, users, countTotal, countNew, countDel, latestCid } = await ( canModerate ?
594
586
// Если это модератор данной фотографии или администратор новости
595
587
commentsTreeBuildCanModerate ( { iAm, type, commentModel, obj, showDel } ) :
596
588
// Если это зарегистрированный пользователь
597
589
commentsTreeBuildAuth ( { iAm, type, commentModel, obj, canReply, showDel } )
598
590
) ;
599
591
600
- return { comments : tree , users, countTotal, countNew, countDel, canModerate, canReply, latestCommentStamp } ;
592
+ return { comments : tree , users, countTotal, countNew, countDel, canModerate, canReply, latestCid } ;
601
593
}
602
594
603
595
// Select comments for object
0 commit comments