git ssb

16+

Dominic / patchbay



Tree: d3a0c5e302f7edc7a52b5002d4c9ad4f2a2d4df3

Files: d3a0c5e302f7edc7a52b5002d4c9ad4f2a2d4df3 / app / page / notifications.js

1682 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': {
15 filter: 'first',
16 scroller: 'first'
17 },
18 'app.sync.goTo': 'first',
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 page = 'notifications'
29
30 return nest({
31 'app.html.menuItem': menuItem,
32 'app.page.notifications': notificationsPage
33 })
34
35 function menuItem () {
36 return h('a', {
37 style: { order: 3 },
38 'ev-click': () => api.app.sync.goTo({ page })
39 }, page)
40 }
41
42 function notificationsPage (location) {
43 const id = api.keys.sync.id()
44
45 const { filterMenu, filterDownThrough, filterUpThrough, resetFeed } = api.app.html.filter(draw)
46 const { container, content } = api.app.html.scroller({ prepend: [ filterMenu ] })
47
48 function draw () {
49 resetFeed({ container, content })
50
51 pull(
52 next(api.feed.pull.mentions(id), {old: false, limit: 100}),
53 filterDownThrough(),
54 Scroller(container, content, api.message.html.render, true, false)
55 )
56
57 pull(
58 next(api.feed.pull.mentions(id), {reverse: true, limit: 100, live: false}),
59 filterUpThrough(),
60 Scroller(container, content, api.message.html.render, false, false)
61 )
62 }
63 draw()
64
65 container.title = page
66 container.id = JSON.stringify(location)
67 return container
68 }
69}
70
71

Built with git-ssb-web