git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: 76bc25fbc6edd50d2de53f58f3033960b0b32a34

Files: 76bc25fbc6edd50d2de53f58f3033960b0b32a34 / modules / profile / html / preview.js

2899 bytesRaw
1var nest = require('depnest')
2var h = require('mutant/h')
3var when = require('mutant/when')
4var computed = require('mutant/computed')
5var send = require('mutant/send')
6
7exports.needs = nest({
8 'about.obs.name': 'first',
9 'about.html.image': 'first',
10 'keys.sync.id': 'first',
11 'sheet.display': 'first',
12 'app.navigate': 'first',
13 'intl.sync.i18n': 'first',
14 'intl.sync.i18n_n': 'first',
15 'sheet.profiles': 'first',
16 'contact.html.followToggle': 'first',
17 'profile.obs.contact': 'first'
18})
19
20exports.gives = nest('profile.html.preview')
21
22exports.create = function (api) {
23 const i18n = api.intl.sync.i18n
24 const plural = api.intl.sync.i18n_n
25
26 return nest('profile.html.preview', function (id) {
27 var name = api.about.obs.name(id)
28 var contact = api.profile.obs.contact(id)
29
30 return h('ProfilePreview', [
31 h('header', [
32 h('div.image', api.about.html.image(id)),
33 h('div.main', [
34 h('div.title', [
35 h('h1', [
36 h('a', {href: id, 'ev-click': () => api.app.navigate(id)}, [name])
37 ]),
38 h('div.meta', [
39 api.contact.html.followToggle(id, {block: false})
40 ])
41 ]),
42 h('section -publicKey', [
43 h('pre', {title: i18n('Public key for this profile')}, id)
44 ])
45 ])
46 ]),
47
48 when(contact.isYou, h('section -you', [
49 i18n('This is you.')
50 ])),
51
52 when(contact.notFollowing, [
53 when(contact.blockingFriendsCount,
54 h('section -blockWarning', [
55 h('a', {
56 href: '#',
57 'ev-click': send(displayBlockingFriends, contact.blockingFriends)
58 }, [
59 '⚠️ ', computed(['This person is blocked by %s of your friends.', contact.blockingFriendsCount], plural)
60 ])
61 ]),
62 when(contact.noIncoming,
63 h('section -distanceWarning', [
64 '⚠️ ', i18n(`You don't follow anyone who follows this person`)
65 ]),
66 when(contact.noOutgoing,
67 h('section -distanceWarning', [
68 '⚠️ ', i18n('This person does not follow anyone that follows you')
69 ]),
70 when(contact.mutualFriendsCount,
71 h('section -mutualFriends', [
72 h('a', {
73 href: '#',
74 'ev-click': send(displayMutualFriends, contact.mutualFriends)
75 }, [
76 '👥 ', computed(['You share %s mutual friends with this person.', contact.mutualFriendsCount], plural)
77 ])
78 ])
79 )
80 )
81 )
82 )
83 ])
84 ])
85 })
86
87 function displayMutualFriends (profiles) {
88 api.sheet.profiles(profiles, i18n('Mutual Friends'))
89 }
90
91 function displayBlockingFriends (profiles) {
92 api.sheet.profiles(profiles, i18n('Blocked by'))
93 }
94}
95

Built with git-ssb-web