Commit 9e3d2a27287664a8a12ac78c22384a9748102890
progress-notifier: snap out of "waiting for sbot" when progress changes
Matt McKegg committed on 9/29/2017, 10:49:27 AMParent: d4131d5fd9230e7811031665045b96e6b8c6eb1d
Files changed
modules/app/html/progress-notifier.js | changed |
modules/app/html/progress-notifier.js | ||
---|---|---|
@@ -19,9 +19,9 @@ | ||
19 | 19 | return nest('app.html.progressNotifier', function (id) { |
20 | 20 | var replicateProgress = api.progress.obs.replicate() |
21 | 21 | var indexes = api.progress.obs.indexes() |
22 | 22 | var migration = api.progress.obs.migration() |
23 | - var waiting = Waiting() | |
23 | + var waiting = Waiting(replicateProgress) | |
24 | 24 | |
25 | 25 | var pending = computed(indexes, (progress) => progress.target - progress.current || 0) |
26 | 26 | var pendingMigration = computed(migration, (progress) => progress.target - progress.current || 0) |
27 | 27 | |
@@ -63,18 +63,17 @@ | ||
63 | 63 | }) |
64 | 64 | |
65 | 65 | // scoped |
66 | 66 | |
67 | - function Waiting () { | |
67 | + function Waiting (progress) { | |
68 | 68 | var waiting = Value() |
69 | 69 | var lastTick = Date.now() |
70 | 70 | |
71 | + progress && progress(update) | |
72 | + | |
71 | 73 | pull( |
72 | 74 | 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) | |
77 | 76 | ) |
78 | 77 | |
79 | 78 | setInterval(function () { |
80 | 79 | if (lastTick < Date.now() - 1000) { |
@@ -82,8 +81,15 @@ | ||
82 | 81 | } |
83 | 82 | }, 1000) |
84 | 83 | |
85 | 84 | return waiting |
85 | + | |
86 | + // scoped | |
87 | + | |
88 | + function update () { | |
89 | + lastTick = Date.now() | |
90 | + waiting.set(false) | |
91 | + } | |
86 | 92 | } |
87 | 93 | } |
88 | 94 | |
89 | 95 | function clamp (value) { |
Built with git-ssb-web