git ssb

2+

mixmix / ticktack



Tree: f3a07a62ed183316f08c7c0cf24dcb767afd29b1

Files: f3a07a62ed183316f08c7c0cf24dcb767afd29b1 / app / html / sideNav / sideNavAddressBook.js

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

Built with git-ssb-web