Files: 140bd2aa4c9baa0075ccea378b2376a4c90cf8fc / app / page / groupFind.js
1883 bytesRaw
1 | const nest = require('depnest') |
2 | const { h, Value, computed, map } = require('mutant') |
3 | |
4 | exports.gives = nest('app.page.groupFind') |
5 | |
6 | exports.needs = nest({ |
7 | 'app.html.link': 'first', |
8 | 'channel.async.suggest': 'first', |
9 | 'translations.sync.strings': 'first' |
10 | }) |
11 | |
12 | exports.create = (api) => { |
13 | return nest('app.page.groupFind', groupFind) |
14 | |
15 | function groupFind (location) { |
16 | const strings = api.translations.sync.strings() |
17 | const input = Value('') |
18 | |
19 | // CHANNEL != GROUP |
20 | // note we're using channels in initial approximation of groups |
21 | const suggester = api.channel.async.suggest() |
22 | const groups = computed(input, input => suggester(input)) |
23 | |
24 | const Link = api.app.html.link |
25 | |
26 | return h('Page -groupFind', {title: strings.groupFind.pageTitle}, [ |
27 | h('div.content', [ |
28 | h('div.search', [ |
29 | h('i.fa.fa-search'), |
30 | h('input', { |
31 | placeholder: strings.groupFind.action.findAGroup, |
32 | autofocus: 'autofocus', |
33 | 'ev-input': e => input.set(e.target.value) |
34 | }) |
35 | ]), |
36 | h('div.results', map(groups, group => { |
37 | return Link({ channel: group.title }, |
38 | h('div.result', [ |
39 | // api.about.html.image(user.id), |
40 | h('div.alias', group.id), // channel with # |
41 | h('pre.key', group.subtitle || ' ') // subscribed or not |
42 | ]) |
43 | ) |
44 | })), |
45 | computed([input, groups], (input, groups) => { |
46 | if (input.length && groups.length === 0) { |
47 | return h('div.groupNotFound', [ |
48 | h('div.info', strings.groupFind.state.groupNotFound), |
49 | Link( |
50 | { page: 'threadNew', channel: input, flash: strings.groupFind.flash.createFirstThread }, |
51 | h('Button -strong', strings.groupFind.action.newGroup) |
52 | ) |
53 | ]) |
54 | } |
55 | }) |
56 | ]) |
57 | ]) |
58 | } |
59 | } |
60 |
Built with git-ssb-web