@decentnetwork/beagle 0.1.89 → 0.1.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/desktop/app.js +7 -3
- package/dist/server.js +19 -2
- package/package.json +1 -1
package/dist/desktop/app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
window.__DK_UI_VERSION="0.1.
|
|
1
|
+
window.__DK_UI_VERSION="0.1.90";
|
|
2
2
|
"use strict";
|
|
3
3
|
(() => {
|
|
4
4
|
// packages/beagle-ui/dist/beagle-ui.js
|
|
@@ -380,11 +380,13 @@ window.__DK_UI_VERSION="0.1.89";
|
|
|
380
380
|
const t = setInterval(refresh, 2500);
|
|
381
381
|
return () => clearInterval(t);
|
|
382
382
|
}, [refresh]);
|
|
383
|
+
const inFlight = React.useRef(/* @__PURE__ */ new Set());
|
|
383
384
|
const loadThread = React.useCallback(async (peerId) => {
|
|
384
|
-
if (!peerId)
|
|
385
|
+
if (!peerId || inFlight.current.has(peerId))
|
|
385
386
|
return;
|
|
387
|
+
inFlight.current.add(peerId);
|
|
386
388
|
try {
|
|
387
|
-
const d = await dkGet("/api/chat-history?peer=" + encodeURIComponent(peerId));
|
|
389
|
+
const d = await dkGet("/api/chat-history?peer=" + encodeURIComponent(peerId) + "&limit=200");
|
|
388
390
|
const arr = d.chats && d.chats[peerId] || [];
|
|
389
391
|
await prefetchThreadFiles(arr);
|
|
390
392
|
const msgs = arr.map((m) => ({
|
|
@@ -417,6 +419,8 @@ window.__DK_UI_VERSION="0.1.89";
|
|
|
417
419
|
const withDay = msgs.length ? [{ day: dkDayLabel(arr[0].ts) }].concat(msgs) : [];
|
|
418
420
|
setThreads((t) => Object.assign({}, t, { [peerId]: withDay }));
|
|
419
421
|
} catch (e) {
|
|
422
|
+
} finally {
|
|
423
|
+
inFlight.current.delete(peerId);
|
|
420
424
|
}
|
|
421
425
|
}, []);
|
|
422
426
|
return Object.assign({}, snap, { threads, refresh, loadThread });
|
package/dist/server.js
CHANGED
|
@@ -2106,8 +2106,25 @@ export function startBeagleServer(opts) {
|
|
|
2106
2106
|
return;
|
|
2107
2107
|
}
|
|
2108
2108
|
if (req.method === "GET" && url === "/api/chat-history") {
|
|
2109
|
-
const
|
|
2110
|
-
const
|
|
2109
|
+
const q = new URL(req.url || "/", "http://x").searchParams;
|
|
2110
|
+
const peer = q.get("peer") || undefined;
|
|
2111
|
+
// A PAGE, never the whole thread. The UI re-polls the open
|
|
2112
|
+
// conversation every 2.5s, and this used to ask for everything each
|
|
2113
|
+
// time: a group with 2000 six-kilobyte bot reports is 12 MB of JSON
|
|
2114
|
+
// per poll per tab, which the daemon could not push over IPC inside
|
|
2115
|
+
// the 30s call timeout. While it tried, its socket stopped answering
|
|
2116
|
+
// the 400ms liveness probe, Beagle declared it gone and dropped the
|
|
2117
|
+
// backend, and the peer list came back empty — a blank chat panel
|
|
2118
|
+
// caused by one busy group. Default 200 is a full screen and then
|
|
2119
|
+
// some; `before` pages further back; the cap keeps a hand-written
|
|
2120
|
+
// URL from recreating the problem. Both `userid` and `peer` are sent:
|
|
2121
|
+
// the daemon reads the first, the embedded host the second, and with
|
|
2122
|
+
// only `userid` the embedded host returned every thread in the store.
|
|
2123
|
+
const lim = Number(q.get("limit") ?? 200);
|
|
2124
|
+
const limit = Number.isFinite(lim) && lim > 0 ? Math.min(lim, 1000) : 200;
|
|
2125
|
+
const bef = Number(q.get("before"));
|
|
2126
|
+
const before = Number.isFinite(bef) && bef > 0 ? bef : undefined;
|
|
2127
|
+
const r = await opts.call({ op: "chat-history", userid: peer, peer, before, limit });
|
|
2111
2128
|
sendJson(res, 200, r.ok ? (r.data ?? { chats: {} }) : { chats: {} });
|
|
2112
2129
|
return;
|
|
2113
2130
|
}
|
package/package.json
CHANGED