Files: c97dd35d6ac1ca1063895d3d37b465813ce27d3d / app / page / notifications.js
1970 bytesRaw
1 | const nest = require('depnest') |
2 | const { h } = require('mutant') |
3 | const pull = require('pull-stream') |
4 | const Scroller = require('pull-scroll') |
5 | const next = require('pull-next-step') |
6 | |
7 | exports.gives = nest({ |
8 | 'app.html.menuItem': true, |
9 | 'app.page.notifications': true |
10 | }) |
11 | |
12 | exports.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 | |
22 | exports.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, property: ['timestamp']}), |
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, property: ['timestamp']}), |
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