Merge pull request #141 from christianbundy/fix-search

Fix search hanging when querying 3 or fewer chars
This commit is contained in:
Cinnamon 2020-02-03 21:34:28 -08:00 committed by GitHub
commit 833e74ae8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 4 deletions

View File

@ -14,6 +14,7 @@
"LGPL",
"Machinekit",
"manyverse",
"minlength",
"monokai",
"msgs",
"multiserver",
@ -31,10 +32,10 @@
"roadmap",
"sameorigin",
"shortname",
"systemctl",
"socio",
"ssbc",
"summerfruit",
"systemctl",
"systemd",
"unfollow",
"unikitty",

View File

@ -507,8 +507,22 @@ exports.replyView = async ({ messages, myFeedId }) => {
);
};
exports.searchView = ({ messages, query }) =>
template(
exports.searchView = ({ messages, query }) => {
const searchInput = input({
name: "query",
required: false,
type: "search",
value: query
});
// - Minimum length of 3 because otherwise SSB-Search hangs forever. :)
// https://github.com/ssbc/ssb-search/issues/8
// - Using `setAttribute()` because HyperScript (the HyperAxe dependency has
// a bug where the `minlength` property is being ignored. No idea why.
// https://github.com/hyperhype/hyperscript/issues/91
searchInput.setAttribute("minlength", 3);
return template(
section(
form(
{ action: "/search", method: "get" },
@ -517,7 +531,7 @@ exports.searchView = ({ messages, query }) =>
{ for: "query" },
"Add word(s) to look for in downloaded messages."
),
input({ required: true, type: "search", name: "query", value: query }),
searchInput,
button(
{
type: "submit"
@ -528,3 +542,4 @@ exports.searchView = ({ messages, query }) =>
),
messages.map(msg => post({ msg }))
);
};