git ssb

2+

mixmix / ticktack



Commit 514fd23969864c14dbe9d94ca098198db7e6624f

minimal private message sidebar

mix irving committed on 9/27/2017, 7:37:21 AM
Parent: 0e65bf76f75d4874321e893134b730597473287e

Files changed

app/html/context.jschanged
app/html/context.mcsschanged
app/html/header.jschanged
package-lock.jsonchanged
package.jsonchanged
app/html/context.jsView
@@ -1,45 +1,73 @@
11 const nest = require('depnest')
2-const { h, computed, map, when } = require('mutant')
2+const { h, computed, map, when, Array: MutantArray } = require('mutant')
3+const pull = require('pull-stream')
4+const next = require('pull-next-step')
35
46 exports.gives = nest('app.html.context')
57
68 exports.needs = nest({
9+ 'about.html.image': 'first',
10+ 'about.obs.name': 'first',
711 'app.html.link': 'first',
12+ 'feed.pull.private': 'first',
13+ 'keys.sync.id': 'first',
814 'translations.sync.strings': 'first',
915 })
1016
1117
1218 exports.create = (api) => {
1319 return nest('app.html.context', (location) => {
1420
1521 const strings = api.translations.sync.strings()
22+ const myKey = api.keys.sync.id()
1623
1724 const discover = {
18- notification: 1,
25+ notifications: Math.floor(Math.random()*5+1),
1926 imageEl: h('i.fa.fa-binoculars'),
2027 name: strings.blogIndex.title,
2128 location: { page: 'blogIndex' },
22- selected: location.page === 'blogIndex' // TODO could be a whole host of pages
29+ selected: ['blogIndex', 'home'].includes(location.page)
2330 }
31+ var nearby = []
2432
25- const nearby = []
26- const friendsWithThreads = []
33+ var recentPeersContacted = MutantArray([])
2734
35+ pull(
36+ next(api.feed.pull.private, {reverse: true, limit: 100, live: false}, ['value', 'timestamp']),
37+ // filterUpThrough(),
38+ pull.filter(msg => msg.value.content.recps),
39+ pull.drain(msg => {
40+ msg.value.content.recps
41+ .map(recp => typeof recp === 'object' ? recp.link : recp)
42+ .filter(recp => recp != myKey)
43+ .forEach(recp => {
44+ if (!recentPeersContacted.includes(recp))
45+ recentPeersContacted.push(recp)
46+ })
47+ })
48+ )
49+
2850 return h('Context -feed', [
2951 h('div.level.-one', [
3052 Option(discover),
3153 map(nearby, Option), // TODO
32- map(friendsWithThreads, Option) // TODO
54+ map(recentPeersContacted, key => Option({
55+ notifications: Math.random() > 0.7 ? Math.floor(Math.random()*9+1) : 0, // TODO
56+ imageEl: api.about.html.image(key), // TODO make avatar
57+ name: api.about.obs.name(key),
58+ location: { page: 'userShow', feed: key },
59+ selected: location.feed === key
60+ }))
3361 ]),
3462 // h('div.level.-two'),
3563 ])
3664
3765
38- function Option ({ notification = 0, imageEl, name, location, selected }) {
66+ function Option ({ notifications = 0, imageEl, name, location, selected }) {
3967 return h('Option', { className: selected ? '-selected' : '' }, [
4068 h('div.circle', [
41- when(notification, h('div.alert', notification)),
69+ when(notifications, h('div.alert', notifications)),
4270 imageEl
4371 ]),
4472 api.app.html.link(location, name),
4573 ])
app/html/context.mcssView
@@ -4,19 +4,16 @@
44 div.level {
55 width: 11rem
66 border-right: 1px gainsboro solid
77
8- display: flex
9- flex-direction: column
10-
118 div.Option {}
129
1310 }
1411 }
1512
1613 Option {
1714 min-width: 8rem
18- padding: 1rem
15+ padding: .5rem 1rem
1916 display: flex
2017 align-items: center
2118
2219 -selected {
app/html/header.jsView
@@ -6,8 +6,9 @@
66
77 exports.needs = nest('keys.sync.id', 'first')
88
99 const FEED_PAGES = [
10+ 'home',
1011 'blogIndex',
1112 // 'blogSearch',
1213 // 'threadShow',
1314 // 'threadNew',
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 199493 bytes
New file size: 200123 bytes
package.jsonView
@@ -36,8 +36,9 @@
3636 "patch-profile": "^1.0.2",
3737 "patch-settings": "^1.0.0",
3838 "patchcore": "^1.10.2",
3939 "pull-next": "^1.0.1",
40+ "pull-next-step": "^1.0.0",
4041 "pull-obv": "^1.3.0",
4142 "pull-stream": "^3.6.0",
4243 "read-directory": "^2.1.0",
4344 "require-style": "^1.0.1",

Built with git-ssb-web