diff options
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static/group-settings.js')
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/static/group-settings.js | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/group-settings.js b/packages/meshbay-hub/src/meshbay_hub/static/group-settings.js index ce36a40..9646405 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/group-settings.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/group-settings.js @@ -42,7 +42,8 @@ import * as platform from './platform.js'; * nodeDetected — whether the loopback node API answers * readOnly — suppress every edit control * onRootsChange — called after a change, to re-read the loopback list - * onRefreshIndex — full index refresh, needed after an add or a remove + * onRefreshIndex — full index refresh. Not called after a root change: see + * `run()` for why the node's own push is what settles it * mode — "live" (default) or "local" * localRoots / onLocalRootsChange — the array, in "local" mode */ @@ -106,18 +107,29 @@ function SharedDirectoriesTable({ roots, groupId, transport, signFn, const rootUrl = (name, suffix = '') => '/api/groups/' + groupId + '/roots/' + encodeURIComponent(name) + suffix; - const run = useCallback(async (work, { refreshIndex = false } = {}) => { + // Deliberately no index refresh after a root change. + // + // Adding a root makes the node reload, which rescans — minutes on a real + // library — and the reload is fire-and-forget for that reason. Fetching the + // index in the moment after therefore returns the set from *before* it, and + // `applyIndex` writes that over the roots the ack had just delivered: the + // new directory appeared for one paint and vanished, which is what "it only + // shows up after a refresh" was. + // + // Nothing is lost by waiting. The ack carries the new table immediately, and + // the delta the node pushes when the scan finishes carries it again along + // with the files. + const run = useCallback(async (work) => { setBusy(true); setMsg(''); try { await work(); if (onRootsChange) await onRootsChange(); - if (refreshIndex && onRefreshIndex) await onRefreshIndex(); return true; } catch (err) { setMsg(platform.bridgeMessage(err)); return false; } finally { setBusy(false); } - }, [onRootsChange, onRefreshIndex]); + }, [onRootsChange]); const doUpdateRoot = useCallback(async (rootName, updates) => { if (isLocal) { @@ -171,7 +183,7 @@ function SharedDirectoriesTable({ roots, groupId, transport, signFn, await platform.node.call('DELETE', rootUrl(rootName)); await platform.node.call('POST', '/api/reload'); } else throw new Error(t('node.root_no_route')); - }, { refreshIndex: true }); + }); if (ok) setMsg(t('node.root_removed')); }, [isLocal, localRoots, onLocalRootsChange, overMnp, overLoopback, transport, groupId, signFn, run]); @@ -203,7 +215,7 @@ function SharedDirectoriesTable({ roots, groupId, transport, signFn, await platform.node.call('POST', '/api/reload'); await platform.watchIndexProgress(groupId, setIndexProgress); } else throw new Error(t('node.root_no_route')); - }, { refreshIndex: true }); + }); }, [isLocal, localRoots, onLocalRootsChange, overMnp, overLoopback, transport, groupId, signFn, run]); |