Files: 1e24c51528660ca6d322ca62c6566f9b047c6412 / app / html / page / notifications.js
1307 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 | 'feed.pull': { |
16 | mentions: 'first', |
17 | public: 'first' |
18 | }, |
19 | 'keys.sync.id': 'first', |
20 | 'app.html.scroller': 'first', |
21 | 'message.html.render': 'first' |
22 | }) |
23 | |
24 | exports.create = function (api) { |
25 | const route = '/notifications' |
26 | |
27 | return nest({ |
28 | 'app.html': { |
29 | page: notificationsPage, |
30 | menuItem: menuItem |
31 | } |
32 | }) |
33 | |
34 | function menuItem (handleClick) { |
35 | return h('a', { |
36 | style: { order: 3 }, |
37 | 'ev-click': () => handleClick(route) |
38 | }, route) |
39 | } |
40 | |
41 | function notificationsPage (path) { |
42 | if (path !== route) return |
43 | const id = api.keys.sync.id() |
44 | const mentions = api.feed.pull.mentions(id) |
45 | |
46 | const { container, content } = api.app.html.scroller({}) |
47 | |
48 | pull( |
49 | next(mentions, {old: false, limit: 100}), |
50 | Scroller(container, content, api.message.html.render, true, false) |
51 | ) |
52 | |
53 | pull( |
54 | next(mentions, {reverse: true, limit: 100, live: false}), |
55 | Scroller(container, content, api.message.html.render, false, false) |
56 | ) |
57 | return container |
58 | } |
59 | } |
60 | |
61 |
Built with git-ssb-web