aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/static/search-page.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static/search-page.js')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/search-page.js24
1 files changed, 21 insertions, 3 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/search-page.js b/packages/meshbay-hub/src/meshbay_hub/static/search-page.js
index ae8eac75..d0150a8e 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/search-page.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/search-page.js
@@ -15,6 +15,7 @@ import { VideoPlayer } from './video-player.js';
import { transfers } from './transfers.js';
import { copyLink, entryPath, groupItemLink } from './copy-link.js';
import { say } from './note.js';
+import { groupLinkRoute } from './group-link.js';
import { mergeUnitEntries } from './source-merge.js';
import { useStickyBand } from './sticky.js';
import { ConnectionPool, MAX_IN_FLIGHT, MAX_POOL_SIZE } from './connection-pool.js';
@@ -139,6 +140,9 @@ async function fetchAllIndexes(pool, groups, token, username, userId, onProgress
const total = groups.length;
let done = 0;
const unreachable = [];
+ // Groups whose node this device refused to reach on the local network: a
+ // setting to change, said apart from the groups that did not answer.
+ const lanBlocked = [];
const downNow = new Set();
const results = new Map();
@@ -168,7 +172,8 @@ async function fetchAllIndexes(pool, groups, token, username, userId, onProgress
downNow.add(g.id);
}
} catch (e) {
- unreachable.push(g.name || g.id);
+ if (e && e.reason === 'local_network_blocked') lanBlocked.push(g);
+ else unreachable.push(g.name || g.id);
// Still refused after transport.js's retries: the hub was busy, which
// says nothing about this group's node, so it keeps its place next time.
if (!(e && e.status === 429)) downNow.add(g.id);
@@ -179,7 +184,7 @@ async function fetchAllIndexes(pool, groups, token, username, userId, onProgress
// A sweep cut short by the page closing saw nothing about any node: every
// group left was refused by this page, not by its node.
if (!(pool && pool.closed)) rememberDown(downNow);
- return { results, unreachable };
+ return { results, unreachable, lanBlocked };
}
// -- SearchPage ---------------------------------------------------------------
@@ -263,6 +268,7 @@ function SearchPage({ token, username, userId, groups, onPlayQueue, userPrefs })
const [indexedGroups, setIndexedGroups] = useState(new Map());
const [progress, setProgress] = useState({ done: 0, total: 0, unreachable: [] });
const [fetching, setFetching] = useState(false);
+ const [lanBlocked, setLanBlocked] = useState([]);
// Bumped by the Files breadcrumb refresh button — re-runs the all-groups
// index fetch below, the only "cache" this page has.
const [refreshTick, setRefreshTick] = useState(0);
@@ -314,9 +320,10 @@ function SearchPage({ token, username, userId, groups, onPlayQueue, userPrefs })
(async () => {
setFetching(true);
setProgress({ done: 0, total: groups.length, unreachable: [] });
+ setLanBlocked([]);
if (!poolRef.current) return;
- const { unreachable } = await fetchAllIndexes(
+ const { unreachable, lanBlocked: refused } = await fetchAllIndexes(
poolRef.current, groups, token, username, userId,
(p) => { if (!cancelled) setProgress(p); },
(results) => { if (!cancelled) setIndexedGroups(new Map(results)); },
@@ -324,6 +331,9 @@ function SearchPage({ token, username, userId, groups, onPlayQueue, userPrefs })
if (cancelled) return;
setFetching(false);
+ // Left up, unlike the line below: there is something to do about it,
+ // and the group page says what (group-page.js explainLanRefusal).
+ setLanBlocked(refused);
// Said once the pass is over, for a few seconds, rather than left above
// the results: by then nothing more can be done about it here, and a
// line that stays is one more thing between the reader and the results.
@@ -714,6 +724,14 @@ function SearchPage({ token, username, userId, groups, onPlayQueue, userPrefs })
`}
</div>
+ ${lanBlocked.length > 0 && html`
+ <p class="settings-hint">
+ ${t('search.lan_blocked', { n: lanBlocked.length })}${' '}
+ ${lanBlocked.map((g, i) => html`${i ? ', ' : ''}<a
+ href=${'#' + groupLinkRoute(g)}>${g.name || g.id}</a>`)}
+ </p>
+ `}
+
${fetching && html`
<div class="search-progress">
<span class="spinner"></span>