Commit 93dc447fa38284caa82c79b12e27c9d0ebda449a
notify when there are additional changes to display, allow refresh
Matt McKegg committed on 10/27/2016, 4:50:34 PMParent: abef5a74d4b427f7a36f20b1be7dc85b9f22080a
Files changed
main-window.js | changed |
views/public-feed.js | changed |
main-window.js | ||
---|---|---|
@@ -112,20 +112,17 @@ | ||
112 | 112 | } |
113 | 113 | |
114 | 114 | function setView (view, ...args) { |
115 | 115 | var newView = [view, ...args] |
116 | + views[view] = screenView(view, ...args) | |
116 | 117 | if (!isSame(newView, currentView())) { |
117 | - if (!views[view]) { | |
118 | - views[view] = screenView(view, ...args) | |
119 | - } | |
120 | - | |
121 | 118 | canGoForward.set(false) |
122 | 119 | canGoBack.set(true) |
123 | 120 | forwardHistory.length = 0 |
124 | 121 | backHistory.push(currentView()) |
125 | - currentView.set(newView) | |
126 | - currentView().scrollTop = 0 | |
127 | 122 | } |
123 | + currentView.set(newView) | |
124 | + currentView().scrollTop = 0 | |
128 | 125 | } |
129 | 126 | |
130 | 127 | function selected (view) { |
131 | 128 | return computed([currentView, view], (currentView, view) => { |
views/public-feed.js | ||
---|---|---|
@@ -18,10 +18,24 @@ | ||
18 | 18 | exports.screen_view = function (path, sbot) { |
19 | 19 | if (path === '/public') { |
20 | 20 | var sync = Value(false) |
21 | 21 | var events = Value([]) |
22 | + var updates = Value(0) | |
22 | 23 | |
24 | + var updateLoader = m('a', { | |
25 | + href: '#', | |
26 | + style: { | |
27 | + 'padding': '10px', | |
28 | + 'display': 'block', | |
29 | + 'background': '#d6e4ec', | |
30 | + 'border': '1px solid #bbc9d2', | |
31 | + 'text-align': 'center' | |
32 | + }, | |
33 | + 'ev-click': refresh | |
34 | + }, [ 'Load ', h('strong', [updates]), ' update(s)' ]) | |
35 | + | |
23 | 36 | var content = h('div.column.scroller__content', [ |
37 | + when(updates, updateLoader), | |
24 | 38 | MutantMap(events, (group) => { |
25 | 39 | if (group.type === 'message') { |
26 | 40 | var meta = null |
27 | 41 | var replies = group.replies.slice(-3).map(message_render) |
@@ -84,29 +98,37 @@ | ||
84 | 98 | content |
85 | 99 | ]) |
86 | 100 | ]) |
87 | 101 | |
102 | + refresh() | |
103 | + | |
88 | 104 | pull( |
89 | - sbot_log({reverse: true, limit: 500, live: false}), | |
90 | - pull.collect((err, values) => { | |
91 | - if (err) throw err | |
92 | - events.set(groupMessages(values)) | |
93 | - sync.set(true) | |
105 | + sbot_log({old: false}), | |
106 | + pull.drain((item) => { | |
107 | + updates.set(updates() + 1) | |
94 | 108 | }) |
95 | 109 | ) |
96 | 110 | |
97 | - | |
98 | 111 | // pull( |
99 | - // sbot_log({old: false}), | |
100 | - // Scroller(div, content, message_render, true, false) | |
101 | - // ) | |
102 | - | |
103 | - // pull( | |
104 | 112 | // u.next(sbot_log, {reverse: true, limit: 100, live: false}), |
105 | 113 | // Scroller(div, content, message_render, false, false) |
106 | 114 | // ) |
107 | 115 | |
108 | 116 | return div |
117 | + | |
118 | + // scoped | |
119 | + | |
120 | + function refresh () { | |
121 | + pull( | |
122 | + sbot_log({reverse: true, limit: 500, live: false}), | |
123 | + pull.collect((err, values) => { | |
124 | + if (err) throw err | |
125 | + events.set(groupMessages(values)) | |
126 | + sync.set(true) | |
127 | + updates.set(0) | |
128 | + }) | |
129 | + ) | |
130 | + } | |
109 | 131 | } |
110 | 132 | } |
111 | 133 | |
112 | 134 | function person (id) { |
Built with git-ssb-web