From c58c397934e0685f6fb27762fc8c56cf69ed2f8a Mon Sep 17 00:00:00 2001 From: ccd0 Date: Tue, 16 Jul 2019 01:05:29 -0700 Subject: [PATCH] Change `Last Reply` sort mode to sort by last unhidden reply. --- src/General/Index.coffee | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/General/Index.coffee b/src/General/Index.coffee index ac43dc2b6..6e1c7a54e 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -807,17 +807,14 @@ Index = sort: -> {liveThreadIDs, liveThreadData} = Index return unless liveThreadData - Index.sortedThreadIDs = switch Index.currentSort.replace(/-rev$/, '') - when 'lastreply' - [liveThreadData...].sort((a, b) -> - 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' + sortType = Index.currentSort.replace(/-rev$/, '') + Index.sortedThreadIDs = switch sortType + when 'lastreply', 'lastlong' lastlong = (thread) -> for r, i in (thread.last_replies or []) by -1 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 if len >= Index.lastLongThresholds[+!!r.ext] return r