Files: b594e41bf900f3f0b270f809fae0596be6cceb54 / app / page / notifications.js
1236 bytesRaw
1 | const nest = require('depnest') |
2 | const { h, onceTrue } = require('mutant') |
3 | const defer = require('pull-defer') |
4 | |
5 | exports.gives = nest('app.page.notifications') |
6 | |
7 | exports.needs = nest({ |
8 | 'app.html.scroller': 'first', |
9 | 'app.html.sideNav': 'first', |
10 | 'message.html.comment': 'first', |
11 | 'sbot.obs.connection': 'first', |
12 | 'translations.sync.strings': 'first' |
13 | }) |
14 | |
15 | exports.create = (api) => { |
16 | return nest('app.page.notifications', function (location) { |
17 | // location here can expected to be: { page: 'notifications', section: * } |
18 | |
19 | if (!location.section) return |
20 | |
21 | var scroller = api.app.html.scroller({ |
22 | classList: ['content'], |
23 | stream: createBlogCommentStream, |
24 | render: Comment |
25 | }) |
26 | |
27 | function createBlogCommentStream (opts) { |
28 | const source = defer.source() |
29 | var resolved = false |
30 | |
31 | onceTrue(api.sbot.obs.connection, server => { |
32 | if (resolved) return |
33 | |
34 | source.resolve(server.ticktack.readAllComments(opts)) |
35 | resolved = true |
36 | }) |
37 | |
38 | return source |
39 | } |
40 | |
41 | return h('Page -notifications', [ |
42 | api.app.html.sideNav(location), |
43 | scroller |
44 | ]) |
45 | |
46 | function Comment (msg) { |
47 | return api.message.html.comment({ comment: msg, showRootLink: true }) |
48 | } |
49 | }) |
50 | } |
51 |
Built with git-ssb-web