git ssb

16+

Dominic / patchbay



Tree: 8069cbb074f6985dedd767cc31ba0586638550ea

Files: 8069cbb074f6985dedd767cc31ba0586638550ea / app / page / notifications.js

1930 bytesRaw
1const nest = require('depnest')
2const { h } = require('mutant')
3const pull = require('pull-stream')
4const Scroller = require('pull-scroll')
5
6const next = require('../../junk/next-stepper')
7
8exports.gives = nest({
9 'app.html.menuItem': true,
10 'app.page.notifications': true
11})
12
13exports.needs = nest({
14 'app.html.filter': 'first',
15 'app.html.scroller': 'first',
16 'app.sync.goTo': 'first',
17 'feed.pull.mentions': 'first',
18 'feed.pull.public': 'first',
19 'keys.sync.id': 'first',
20 'message.html.render': 'first'
21})
22
23exports.create = function (api) {
24 return nest({
25 'app.html.menuItem': menuItem,
26 'app.page.notifications': notificationsPage
27 })
28
29 function menuItem () {
30 return h('a', {
31 style: { order: 3 },
32 'ev-click': () => api.app.sync.goTo({ page: 'notifications' })
33 }, '/notifications')
34 }
35
36 function notificationsPage (location) {
37 const id = api.keys.sync.id()
38
39 const { filterMenu, filterDownThrough, filterUpThrough, resetFeed } = api.app.html.filter(draw)
40 const { container, content } = api.app.html.scroller({ prepend: [ filterMenu ] })
41 const removeMyMessages = () => pull.filter(msg => msg.value.author !== id)
42 const removePrivateMessages = () => pull.filter(msg => msg.value.private !== true)
43
44 function draw () {
45 resetFeed({ container, content })
46
47 pull(
48 next(api.feed.pull.mentions(id), {old: false, limit: 100}),
49 removeMyMessages(),
50 removePrivateMessages(),
51 filterDownThrough(),
52 Scroller(container, content, api.message.html.render, true, false)
53 )
54
55 pull(
56 next(api.feed.pull.mentions(id), {reverse: true, limit: 100, live: false}),
57 removeMyMessages(),
58 removePrivateMessages(),
59 filterUpThrough(),
60 Scroller(container, content, api.message.html.render, false, false)
61 )
62 }
63 draw()
64
65 container.title = '/notifications'
66 return container
67 }
68}
69

Built with git-ssb-web