Files: 8c68dbb9a3b69a0cf0e0dd503ef059a873189cd5 / app / html / sideNav / sideNavAddressBook.js
2304 bytesRaw
1 | const nest = require('depnest') |
2 | const { h, computed, Struct, map, when, Dict, Array: MutantArray, Value, Set, resolve } = require('mutant') |
3 | const pull = require('pull-stream') |
4 | const next = require('pull-next-step') |
5 | const get = require('lodash/get') |
6 | const isEmpty = require('lodash/isEmpty') |
7 | const path = require('path') |
8 | |
9 | exports.gives = nest({ |
10 | 'app.html.sideNav': true, |
11 | }) |
12 | |
13 | exports.needs = nest({ |
14 | // 'app.html.scroller': 'first', |
15 | // 'about.html.avatar': 'first', |
16 | // 'about.obs.name': 'first', |
17 | // 'feed.pull.private': 'first', |
18 | 'history.sync.push': 'first', |
19 | // 'message.html.subject': 'first', |
20 | // 'sbot.obs.localPeers': 'first', |
21 | 'translations.sync.strings': 'first', |
22 | // 'unread.sync.isUnread': 'first' |
23 | }) |
24 | |
25 | exports.create = (api) => { |
26 | return nest({ |
27 | 'app.html.sideNav': sideNav, |
28 | }) |
29 | |
30 | function sideNav (location, relationships) { |
31 | if (location.page !== 'addressBook') return |
32 | if (!location.section) location.section = 'friends' |
33 | |
34 | const strings = api.translations.sync.strings().addressBook |
35 | const goTo = (loc) => () => api.history.sync.push(loc) |
36 | |
37 | // TODO - show local peers? |
38 | // var nearby = api.sbot.obs.localPeers() |
39 | |
40 | return h('SideNav -addressBook', [ |
41 | LevelOneSideNav(), |
42 | ]) |
43 | |
44 | function LevelOneSideNav () { |
45 | return h('div.level.-one', [ |
46 | h('section', [ |
47 | SectionOption('search', [ |
48 | h('Button -primary', {}, strings.action.addUser) |
49 | ]), |
50 | h('hr'), |
51 | ]), |
52 | |
53 | //Friends |
54 | h('section', [ |
55 | h('header',strings.heading.people), |
56 | SectionOption('friends'), |
57 | SectionOption('following'), |
58 | SectionOption('followers'), |
59 | ]) |
60 | ]) |
61 | } |
62 | |
63 | function SectionOption (section, body) { |
64 | const className = section === location.section |
65 | ? '-selected' |
66 | : '' |
67 | return h('Option', |
68 | { className, 'ev-click': goTo({page: 'addressBook', section }) }, |
69 | body || defaulBody(section) |
70 | ) |
71 | |
72 | function defaulBody (section) { |
73 | return [ |
74 | h('i.fa.fa-angle-right'), |
75 | strings.section[section], |
76 | h('div.count', count(section)) |
77 | ] |
78 | } |
79 | } |
80 | |
81 | function count (relationshipType) { |
82 | return computed(relationships, rels => rels[relationshipType].length) |
83 | } |
84 | } |
85 | } |
86 | |
87 | |
88 |
Built with git-ssb-web