git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Commit 93dc447fa38284caa82c79b12e27c9d0ebda449a

notify when there are additional changes to display, allow refresh

Matt McKegg committed on 10/27/2016, 4:50:34 PM
Parent: abef5a74d4b427f7a36f20b1be7dc85b9f22080a

Files changed

main-window.jschanged
views/public-feed.jschanged
main-window.jsView
@@ -112,20 +112,17 @@
112112 }
113113
114114 function setView (view, ...args) {
115115 var newView = [view, ...args]
116+ views[view] = screenView(view, ...args)
116117 if (!isSame(newView, currentView())) {
117- if (!views[view]) {
118- views[view] = screenView(view, ...args)
119- }
120-
121118 canGoForward.set(false)
122119 canGoBack.set(true)
123120 forwardHistory.length = 0
124121 backHistory.push(currentView())
125- currentView.set(newView)
126- currentView().scrollTop = 0
127122 }
123+ currentView.set(newView)
124+ currentView().scrollTop = 0
128125 }
129126
130127 function selected (view) {
131128 return computed([currentView, view], (currentView, view) => {
views/public-feed.jsView
@@ -18,10 +18,24 @@
1818 exports.screen_view = function (path, sbot) {
1919 if (path === '/public') {
2020 var sync = Value(false)
2121 var events = Value([])
22+ var updates = Value(0)
2223
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+
2336 var content = h('div.column.scroller__content', [
37+ when(updates, updateLoader),
2438 MutantMap(events, (group) => {
2539 if (group.type === 'message') {
2640 var meta = null
2741 var replies = group.replies.slice(-3).map(message_render)
@@ -84,29 +98,37 @@
8498 content
8599 ])
86100 ])
87101
102+ refresh()
103+
88104 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)
94108 })
95109 )
96110
97-
98111 // pull(
99- // sbot_log({old: false}),
100- // Scroller(div, content, message_render, true, false)
101- // )
102-
103- // pull(
104112 // u.next(sbot_log, {reverse: true, limit: 100, live: false}),
105113 // Scroller(div, content, message_render, false, false)
106114 // )
107115
108116 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+ }
109131 }
110132 }
111133
112134 function person (id) {

Built with git-ssb-web