git ssb

16+

Dominic / patchbay



Tree: 462ecf99d74af355e56473beb952b48ef1043d19

Files: 462ecf99d74af355e56473beb952b48ef1043d19 / app / html / page / notifications.js

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

Built with git-ssb-web