git ssb

10+

Matt McKegg / patchwork



Commit 5f50f29bceb6b28fde2a1ab352fe976f4576690a

search: suggest pages when '/' typed

Matt McKegg committed on 4/23/2017, 5:56:19 AM
Parent: a61adf51b6aeb00c6018ce2fb80cba9383b52625

Files changed

modules/app/html/search.jschanged
modules/app/html/search.jsView
@@ -8,8 +8,10 @@
88 })
99
1010 exports.gives = nest('app.html.search')
1111
12 +var pages = ['/public', '/private', '/mentions', '/all']
13 +
1214 exports.create = function (api) {
1315 return nest('app.html.search', function (setView) {
1416 var getProfileSuggestions = api.profile.async.suggest()
1517 var getChannelSuggestions = api.channel.async.suggest()
@@ -33,8 +35,10 @@
3335 if (inputText[0] === '@') {
3436 cb(null, getProfileSuggestions(inputText.slice(1)), {idOnly: true})
3537 } else if (inputText[0] === '#') {
3638 cb(null, getChannelSuggestions(inputText.slice(1)))
39 + } else if (inputText[0] === '/') {
40 + cb(null, getPageSuggestions(inputText))
3741 }
3842 }, {cls: 'SuggestBox'})
3943 })
4044
@@ -53,6 +57,16 @@
5357 setView(`?${value.trim()}`)
5458 }
5559 }
5660 }
61 +
62 + function getPageSuggestions (input) {
63 + return pages.sort().filter(p => p.startsWith(input.toLowerCase())).map(p => {
64 + return {
65 + id: p,
66 + value: p,
67 + title: p
68 + }
69 + })
70 + }
5771 })
5872 }

Built with git-ssb-web