Files: c38e965ff14b9067041ae577f0d73337d043aebf / app / html / page / notifications.js
1620 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('../../../junk/next-stepper') |
6 | |
7 | exports.gives = nest({ |
8 | 'app.html': { |
9 | page: true, |
10 | menuItem: true |
11 | } |
12 | }) |
13 | |
14 | exports.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 | |
28 | exports.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