From 7118c71695885065392c4b64b31299eb545ef417 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Mon, 18 Nov 2013 12:06:03 +0100 Subject: [PATCH] Index sort tweak: search before sorting sticky/pinned threads. That way we only have to sort the matched threads when searching. --- src/General/Index.coffee | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/General/Index.coffee b/src/General/Index.coffee index e65368973..834b8e517 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -325,18 +325,19 @@ Index = for threadID in sortedThreadIDs i = Index.liveThreadIDs.indexOf(threadID) * 2 Index.sortedNodes.push Index.nodes[i], Index.nodes[i + 1] + if Index.isSearching + Index.sortedNodes = Index.querySearch(Index.searchInput.value) or Index.sortedNodes # Put the sticky threads on top of the index. offset = 0 for threadRoot, i in Index.sortedNodes by 2 when Get.threadFromRoot(threadRoot).isSticky Index.sortedNodes.splice offset++ * 2, 0, Index.sortedNodes.splice(i, 2)... - if Conf['Filter'] - # Put the highlighted thread &
on top of the index - # while keeping the original order they appear in. - offset = 0 - for threadRoot, i in Index.sortedNodes by 2 when Get.threadFromRoot(threadRoot).isOnTop - Index.sortedNodes.splice offset++ * 2, 0, Index.sortedNodes.splice(i, 2)... - if Index.isSearching - Index.sortedNodes = Index.querySearch(Index.searchInput.value) or Index.sortedNodes + return unless Conf['Filter'] + # Put the highlighted thread &
on top of the index + # while keeping the original order they appear in. + offset = 0 + for threadRoot, i in Index.sortedNodes by 2 when Get.threadFromRoot(threadRoot).isOnTop + Index.sortedNodes.splice offset++ * 2, 0, Index.sortedNodes.splice(i, 2)... + return buildIndex: -> if Conf['Index Mode'] is 'paged' pageNum = Index.getCurrentPage()