Files: 9510d7867738dfa7a4aaee17c183c86bb081f55e / app / page / notifications.js
1683 bytesRaw
1 | const nest = require('depnest') |
2 | const { h } = require('mutant') |
3 | const pull = require('pull-stream') |
4 | const Scroller = require('pull-scroll') |
5 | |
6 | const next = require('../../junk/next-stepper') |
7 | |
8 | exports.gives = nest({ |
9 | 'app.html.menuItem': true, |
10 | 'app.page.notifications': true |
11 | }) |
12 | |
13 | exports.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 | |
27 | exports.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