Commit 920f29c78bb0076a529cda4bbc4f01b19cabd924
wip
mix irving committed on 7/4/2018, 11:27:56 PMParent: 9ad609d054fd59c134b3aac1b801d0aa7d8d0e5a
Files changed
app/page/posts.js | changed |
app/page/posts.js | ||
---|---|---|
@@ -39,63 +39,74 @@ | ||
39 | 39 … | }, '/posts') |
40 | 40 … | } |
41 | 41 … | |
42 | 42 … | function postsPage (location) { |
43 | - const BY_UPDATE = 'by_update' | |
44 | - const BY_ROOT = 'by_root' | |
43 … | + const BY_UPDATE = 'by update' | |
44 … | + const BY_ROOT = 'by root' | |
45 | 45 … | |
46 | - const composer = api.message.html.compose({ | |
47 | - location, | |
48 | - meta: { type: 'post' }, | |
49 | - placeholder: 'Write a public message' | |
50 | - }) | |
46 … | + const state = Value(BY_UPDATE) | |
47 … | + const viewSettings = h('section.viewSettings', [ | |
48 … | + h('button', 'hey!') | |
49 … | + ]) | |
51 | 50 … | |
52 | - const store = MutantArray([]) | |
51 … | + return computed(state, state => { | |
52 … | + var page = byUpdatePage() | |
53 | 53 … | |
54 | - const page = Scroller({ | |
55 | - classList: ['Posts'], | |
56 | - prepend: [ | |
57 | - composer | |
58 | - ], | |
59 | - streamToTop: createStream({ live: true, old: false }), | |
60 | - streamToBottom: createStream({ reverse: true }), | |
61 | - store, | |
62 | - updateTop: (soFar, msg) => { | |
63 | - const root = getRoot(msg) | |
64 | - if (soFar.includes(root)) soFar.delete(root) | |
65 | - soFar.insert(root) | |
66 | - }, | |
67 | - updateBottom: (soFar, msg) => { | |
68 | - const root = getRoot(msg) | |
69 | - if (!soFar.includes(root)) soFar.push(root) | |
70 | - }, | |
71 | - render | |
54 … | + page.title = '/posts' | |
55 … | + page.scroll = keyscroll(page.querySelector('section.content')) | |
56 … | + return page | |
72 | 57 … | }) |
73 | 58 … | |
74 | - function createStream (opts) { | |
75 | - return api.sbot.pull.stream(server => { | |
76 | - // by_update - stream by receive time | |
77 | - const defaults = { | |
78 | - limit: 50, | |
79 | - query: [{ | |
80 | - $filter: { | |
81 | - timestamp: { $gt: 0 }, | |
82 | - value: { | |
83 | - content: { | |
84 | - type: 'post', | |
85 | - recps: { $not: true } | |
59 … | + function byUpdatePage () { | |
60 … | + return Scroller({ | |
61 … | + classList: ['Posts'], | |
62 … | + prepend: [ | |
63 … | + viewSettings, | |
64 … | + Composer(location) | |
65 … | + ], | |
66 … | + streamToTop: createStream({ live: true, old: false }), | |
67 … | + streamToBottom: createStream({ reverse: true }), | |
68 … | + updateTop: (soFar, msg) => { | |
69 … | + const root = getRoot(msg) | |
70 … | + if (soFar.includes(root)) soFar.delete(root) | |
71 … | + soFar.insert(root) | |
72 … | + }, | |
73 … | + updateBottom: (soFar, msg) => { | |
74 … | + const root = getRoot(msg) | |
75 … | + if (!soFar.includes(root)) soFar.push(root) | |
76 … | + }, | |
77 … | + render | |
78 … | + }) | |
79 … | + | |
80 … | + function createStream (opts) { | |
81 … | + return api.sbot.pull.stream(server => { | |
82 … | + // by_update - stream by receive time | |
83 … | + const defaults = { | |
84 … | + limit: 50, | |
85 … | + query: [{ | |
86 … | + $filter: { | |
87 … | + timestamp: { $gt: 0 }, | |
88 … | + value: { | |
89 … | + content: { | |
90 … | + type: 'post', | |
91 … | + recps: { $not: true } | |
92 … | + } | |
86 | 93 … | } |
87 | 94 … | } |
88 | - } | |
89 | - }] | |
90 | - } | |
91 | - return next(server.query.read, merge({}, defaults, opts), ['timestamp']) | |
92 | - }) | |
95 … | + }] | |
96 … | + } | |
97 … | + return next(server.query.read, merge({}, defaults, opts), ['timestamp']) | |
98 … | + }) | |
99 … | + } | |
93 | 100 … | } |
101 … | + } | |
94 | 102 … | |
95 | - page.title = '/posts' | |
96 | - page.scroll = keyscroll(page.querySelector('section.content')) | |
97 | - return page | |
103 … | + function Composer (location) { | |
104 … | + return api.message.html.compose({ | |
105 … | + location, | |
106 … | + meta: { type: 'post' }, | |
107 … | + placeholder: 'Write a public message' | |
108 … | + }) | |
98 | 109 … | } |
99 | 110 … | |
100 | 111 … | // TODO - move out into message.html.render ? |
101 | 112 … | function render (key) { |
Built with git-ssb-web