Files: 8a51c32a71a79eaf5aacc86fda73831f1a6356dc / app / page / profile.js
1956 bytesRaw
1 | const nest = require('depnest') |
2 | const Scroller = require('pull-scroll') |
3 | const pull = require('pull-stream') |
4 | const { h, watch } = require('mutant') |
5 | const next = require('pull-next-query') |
6 | |
7 | exports.gives = nest({ |
8 | 'app.html.menuItem': true, |
9 | 'app.page.profile': true |
10 | }) |
11 | |
12 | exports.needs = nest({ |
13 | 'about.html.edit': 'first', |
14 | 'about.obs.name': 'first', |
15 | 'app.html.scroller': 'first', |
16 | 'app.sync.goTo': 'first', |
17 | 'contact.html.relationships': 'first', |
18 | 'keys.sync.id': 'first', |
19 | 'message.html.render': 'first', |
20 | 'sbot.pull.stream': 'first' |
21 | }) |
22 | |
23 | exports.create = function (api) { |
24 | return nest({ |
25 | 'app.html.menuItem': menuItem, |
26 | 'app.page.profile': profilePage |
27 | }) |
28 | |
29 | function menuItem () { |
30 | return h('a', { |
31 | style: { order: 0 }, |
32 | 'ev-click': () => api.app.sync.goTo(api.keys.sync.id()) |
33 | }, '/profile') |
34 | } |
35 | |
36 | function profilePage (location) { |
37 | const { feed: id } = location |
38 | const profile = h('Profile', [ |
39 | h('section.edit', api.about.html.edit(id)), |
40 | h('section.relationships', api.contact.html.relationships(id)), |
41 | h('section.activity', [ |
42 | h('header', 'Activity') |
43 | // ideally the scroller content would go in here |
44 | ]) |
45 | ]) |
46 | |
47 | var { container, content } = api.app.html.scroller({ prepend: profile }) |
48 | |
49 | const source = (opts) => api.sbot.pull.stream(s => next(s.query.read, opts, ['value', 'timestamp'])) |
50 | const query = [{ |
51 | $filter: { |
52 | value: { |
53 | timestamp: { $gt: 0 }, |
54 | author: id |
55 | } |
56 | } |
57 | }] |
58 | |
59 | pull( |
60 | source({ query, live: true, old: false }), |
61 | Scroller(container, content, api.message.html.render, true, false) |
62 | ) |
63 | |
64 | // how to handle when have scrolled past the start??? |
65 | |
66 | pull( |
67 | source({ query, reverse: true, limit: 50 }), |
68 | Scroller(container, content, api.message.html.render, false, false) |
69 | ) |
70 | |
71 | watch(api.about.obs.name(id), name => { container.title = '@' + name }) |
72 | return container |
73 | } |
74 | } |
75 |
Built with git-ssb-web