git ssb

16+

Dominic / patchbay



Tree: 155cb7d3bab180ae158641a9c5d8413332bacdfc

Files: 155cb7d3bab180ae158641a9c5d8413332bacdfc / app / page / notifications.js

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

Built with git-ssb-web