From ebe7f11d0b410d03bb2367945ec04f0924f453c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 27 Oct 2021 14:21:36 -0400 Subject: [PATCH] merge --- src/search.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/search.js b/src/search.js index 99fae633e8..0a0d1f459c 100644 --- a/src/search.js +++ b/src/search.js @@ -56,10 +56,19 @@ async function searchInContent(data) { } return []; } - const [pids, tids] = await Promise.all([ - doSearch('post', ['posts', 'titlesposts']), - doSearch('topic', ['titles', 'titlesposts']), - ]); + let pids = []; + let tids = []; + const inTopic = String(data.query || '').match(/^in:topic-([\d]+) /); + if (inTopic) { + const tid = inTopic[1]; + const cleanedTerm = data.query.replace(inTopic[0], ''); + pids = await topics.search(tid, cleanedTerm); + } else { + [pids, tids] = await Promise.all([ + doSearch('post', ['posts', 'titlesposts']), + doSearch('topic', ['titles', 'titlesposts']), + ]); + } if (data.returnIds) { return { pids: pids, tids: tids };