git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Commit 9e3d2a27287664a8a12ac78c22384a9748102890

progress-notifier: snap out of "waiting for sbot" when progress changes

Matt McKegg committed on 9/29/2017, 10:49:27 AM
Parent: d4131d5fd9230e7811031665045b96e6b8c6eb1d

Files changed

modules/app/html/progress-notifier.jschanged
modules/app/html/progress-notifier.jsView
@@ -19,9 +19,9 @@
1919 return nest('app.html.progressNotifier', function (id) {
2020 var replicateProgress = api.progress.obs.replicate()
2121 var indexes = api.progress.obs.indexes()
2222 var migration = api.progress.obs.migration()
23- var waiting = Waiting()
23+ var waiting = Waiting(replicateProgress)
2424
2525 var pending = computed(indexes, (progress) => progress.target - progress.current || 0)
2626 var pendingMigration = computed(migration, (progress) => progress.target - progress.current || 0)
2727
@@ -63,18 +63,17 @@
6363 })
6464
6565 // scoped
6666
67- function Waiting () {
67+ function Waiting (progress) {
6868 var waiting = Value()
6969 var lastTick = Date.now()
7070
71+ progress && progress(update)
72+
7173 pull(
7274 api.sbot.pull.stream(sbot => sbot.patchwork.heartbeat()),
73- pull.drain((tick) => {
74- lastTick = Date.now()
75- waiting.set(false)
76- })
75+ pull.drain(update)
7776 )
7877
7978 setInterval(function () {
8079 if (lastTick < Date.now() - 1000) {
@@ -82,8 +81,15 @@
8281 }
8382 }, 1000)
8483
8584 return waiting
85+
86+ // scoped
87+
88+ function update () {
89+ lastTick = Date.now()
90+ waiting.set(false)
91+ }
8692 }
8793 }
8894
8995 function clamp (value) {

Built with git-ssb-web