git ssb

16+

Dominic / patchbay



Commit 415b47a27b9856dd3a3af7369179437cc4f1be13

Add feed navigation suggestions

Charles Lehner committed on 6/30/2016, 2:38:23 PM
Parent: 86a49874288e82f64d807b5c7c48c43955d3aec3

Files changed

modules/search-box.jschanged
modules/tabs.jschanged
modules/search-box.jsView
@@ -2,8 +2,9 @@
22 var suggest = require('suggest-box')
33 var pull = require('pull-stream')
44 var plugs = require('../plugs')
55 var sbot_query = plugs.first(exports.sbot_query = [])
6+var sbot_links2 = plugs.first(exports.sbot_links2 = [])
67
78 exports.search_box = function (go) {
89
910 var suggestBox
@@ -37,8 +38,15 @@
3738 search.value = sigil
3839 }
3940 }
4041
42+ var suggestions = {}
43+
44+ // delay until the element has a parent
45+ setTimeout(function () {
46+ suggestBox = suggest(search, suggestions)
47+ }, 10)
48+
4149 pull(
4250 sbot_query({query: [
4351 {$filter: {value: {content: {channel: {$gt: ''}}}}},
4452 {$reduce: {
@@ -47,18 +55,41 @@
4755 }}
4856 ]}),
4957 pull.collect(function (err, chans) {
5058 if (err) return console.error(err)
51- var suggestions = chans.map(function (chan) {
59+ suggestions['#'] = chans.map(function (chan) {
5260 var name = '#' + chan.channel
53- if (name) return {
61+ return {
5462 title: name,
5563 value: name,
5664 subtitle: chan.posts
5765 }
58- }).filter(Boolean)
59- suggestBox = suggest(search, {'#': suggestions})
66+ })
6067 })
6168 )
6269
70+ pull(
71+ sbot_links2({query: [
72+ {$filter: {
73+ dest: {$prefix: '@'},
74+ rel: ['mentions', {$gt: '@'}]}
75+ },
76+ {$reduce: {
77+ id: 'dest',
78+ name: ['rel', 1],
79+ rank: {$count: true}}
80+ }
81+ ]}),
82+ pull.collect(function (err, links) {
83+ if (err) return console.error(err)
84+ suggestions['@'] = links.map(function (e) {
85+ return {
86+ title: e.name,
87+ value: e.id,
88+ subtitle: e.id + ' (' + e.rank + ')'
89+ }
90+ })
91+ })
92+ )
93+
6394 return search
6495 }
modules/tabs.jsView
@@ -116,8 +116,14 @@
116116 case 191: // /
117117 search.activate('?', ev)
118118 return
119119
120+ // navigate to a feed
121+ case 50: // 2
122+ if (ev.shiftKey)
123+ search.activate('@', ev)
124+ return
125+
120126 // navigate to a channel
121127 case 51: // 3
122128 if (ev.shiftKey)
123129 search.activate('#', ev)

Built with git-ssb-web