diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-11-25 17:48:51 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-25 17:48:51 -0600 |
| commit | a391956c967a7c436ce6fabdbbd8ddcbda562e26 (patch) | |
| tree | 8b7b2bbaeffb1b90e310a8e2a7e913bf2592127a /src/web | |
| parent | a99d796464528e2add10b358a3344b7c1d1278dd (diff) | |
| parent | fd72cac19e6beaa2ec6377b791f9b3d0bbd88d94 (diff) | |
| download | slskd-a391956c967a7c436ce6fabdbbd8ddcbda562e26.tar.gz | |
Merge pull request #783 from slskd/shares
Update the shares UI when config changes, or after scanning
Diffstat (limited to 'src/web')
| -rw-r--r-- | src/web/src/components/System/Shares/ShareTable.js | 4 | ||||
| -rw-r--r-- | src/web/src/components/System/Shares/index.js | 16 |
2 files changed, 12 insertions, 8 deletions
diff --git a/src/web/src/components/System/Shares/ShareTable.js b/src/web/src/components/System/Shares/ShareTable.js index 095a8380..fd2c7623 100644 --- a/src/web/src/components/System/Shares/ShareTable.js +++ b/src/web/src/components/System/Shares/ShareTable.js @@ -35,8 +35,8 @@ const ShareTable = ({ shares, onClick }) => { <Icon name='folder'/> <Link to='#'>{share.localPath}</Link> </Table.Cell> - <Table.Cell>{share.directories}</Table.Cell> - <Table.Cell>{share.files}</Table.Cell> + <Table.Cell>{share.directories ?? '?'}</Table.Cell> + <Table.Cell>{share.files ?? '?'}</Table.Cell> <Table.Cell>{share.alias}</Table.Cell> <Table.Cell>{share.remotePath}</Table.Cell> </Table.Row>))} diff --git a/src/web/src/components/System/Shares/index.js b/src/web/src/components/System/Shares/index.js index f4f9ac94..3d5b1858 100644 --- a/src/web/src/components/System/Shares/index.js +++ b/src/web/src/components/System/Shares/index.js @@ -24,21 +24,25 @@ const Index = ({ state = {} } = {}) => { const [modal, setModal] = useState(false); const { scanning, scanProgress, scanPending, directories, files } = state; - const scanned = !scanning; useEffect(() => { getAll(); }, []); useEffect(() => { - if (scanned) { - getAll(); + getAll({ quiet: true }); + + if (!scanning) { + // the state change out of scanning can fire before + // shares are updated, which leaves them stale. wait a second + // and fetch again. + setTimeout(() => getAll({ quiet: true }), 1000); } - }, [scanned]); + }, [scanning, scanPending]); - const getAll = async () => { + const getAll = async ({ quiet } = { quiet: false }) => { try { - setLoading(true); + if (!quiet) setLoading(true); const sharesByHost = await sharesLib.getAll(); const flattened = Object.entries(sharesByHost).reduce((acc, [host, shares]) => { |
