git ssb

16+

Dominic / patchbay



Tree: 91116b86a5d782a02e668da8c5990803728c90d4

Files: 91116b86a5d782a02e668da8c5990803728c90d4 / app / html / page / notifications.js

1620 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 'app.sync.goTo': 'first',
20 'feed.pull': {
21 mentions: 'first',
22 public: 'first'
23 },
24 'keys.sync.id': 'first',
25 'message.html.render': 'first'
26})
27
28exports.create = function (api) {
29 const route = '/notifications'
30
31 return nest({
32 'app.html': {
33 page: notificationsPage,
34 menuItem
35 }
36 })
37
38 function menuItem () {
39 return h('a', {
40 style: { order: 3 },
41 'ev-click': () => api.app.sync.goTo(route)
42 }, route)
43 }
44
45 function notificationsPage (path) {
46 if (path !== route) return
47
48 const id = api.keys.sync.id()
49
50 const { filterMenu, filterDownThrough, filterUpThrough, resetFeed } = api.app.html.filter(draw)
51 const { container, content } = api.app.html.scroller({ prepend: [ filterMenu ] })
52
53 function draw () {
54 resetFeed({ container, content })
55
56 pull(
57 next(api.feed.pull.mentions(id), {old: false, limit: 100}),
58 filterDownThrough(),
59 Scroller(container, content, api.message.html.render, true, false)
60 )
61
62 pull(
63 next(api.feed.pull.mentions(id), {reverse: true, limit: 100, live: false}),
64 filterUpThrough(),
65 Scroller(container, content, api.message.html.render, false, false)
66 )
67 }
68 draw()
69
70 return container
71 }
72}
73
74

Built with git-ssb-web