Change Last Reply sort mode to sort by last unhidden reply.

This commit is contained in:
ccd0 2019-07-16 01:05:29 -07:00
parent ead54c6e92
commit c58c397934

View File

@ -807,17 +807,14 @@ Index =
sort: -> sort: ->
{liveThreadIDs, liveThreadData} = Index {liveThreadIDs, liveThreadData} = Index
return unless liveThreadData return unless liveThreadData
Index.sortedThreadIDs = switch Index.currentSort.replace(/-rev$/, '') sortType = Index.currentSort.replace(/-rev$/, '')
when 'lastreply' Index.sortedThreadIDs = switch sortType
[liveThreadData...].sort((a, b) -> when 'lastreply', 'lastlong'
a = num[num.length - 1] if (num = a.last_replies)
b = num[num.length - 1] if (num = b.last_replies)
b.no - a.no
).map (post) -> post.no
when 'lastlong'
lastlong = (thread) -> lastlong = (thread) ->
for r, i in (thread.last_replies or []) by -1 for r, i in (thread.last_replies or []) by -1
continue if Index.isHiddenReply thread.no, r continue if Index.isHiddenReply thread.no, r
if sortType is 'lastreply'
return r
len = if r.com then g.SITE.Build.parseComment(r.com).replace(/[^a-z]/ig, '').length else 0 len = if r.com then g.SITE.Build.parseComment(r.com).replace(/[^a-z]/ig, '').length else 0
if len >= Index.lastLongThresholds[+!!r.ext] if len >= Index.lastLongThresholds[+!!r.ext]
return r return r