@decentnetwork/beagle-ui 0.2.23 → 0.2.25
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/beagle-ui.js +87 -9
- package/package.json +1 -1
package/dist/beagle-ui.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const BEAGLE_UI_VERSION = "0.2.
|
|
1
|
+
export const BEAGLE_UI_VERSION = "0.2.25";
|
|
2
2
|
// src/icons.jsx
|
|
3
3
|
var ICON_PATHS = {
|
|
4
4
|
// ---- tab bar (the four must feel like one set) ----
|
|
@@ -877,6 +877,12 @@ var service_peers_default = {
|
|
|
877
877
|
kind: "node",
|
|
878
878
|
role: "server"
|
|
879
879
|
},
|
|
880
|
+
{
|
|
881
|
+
userid: "5SxEBHAx49Hknq1VzrA1HDtZHjW31vetX3iMEi4P6pK3",
|
|
882
|
+
name: "gfax118",
|
|
883
|
+
kind: "node",
|
|
884
|
+
role: "server"
|
|
885
|
+
},
|
|
880
886
|
{
|
|
881
887
|
userid: "72a4A7awtn6BqZnBt3eNhZH9MdYXRkM6Ht5HG2sqoiKR",
|
|
882
888
|
name: "nv4090-wsl",
|
|
@@ -1164,6 +1170,7 @@ ${cmds}
|
|
|
1164
1170
|
|
|
1165
1171
|
${tail}`;
|
|
1166
1172
|
}
|
|
1173
|
+
var SKIP_NAMES_MAX = 10;
|
|
1167
1174
|
var seq = 0;
|
|
1168
1175
|
var asMsg = (from, text, extra) => Object.assign({
|
|
1169
1176
|
id: `as-${Date.now()}-${seq++}`,
|
|
@@ -1225,22 +1232,29 @@ function useAssistant({ lang, T, muted, onToggleMute, sound, flash, setAlert, on
|
|
|
1225
1232
|
ver: r.beagleVer || ""
|
|
1226
1233
|
};
|
|
1227
1234
|
};
|
|
1235
|
+
const skipLine = (skipped) => {
|
|
1236
|
+
if (!skipped.length)
|
|
1237
|
+
return "";
|
|
1238
|
+
const shown = skipped.slice(0, SKIP_NAMES_MAX).map(nameOf);
|
|
1239
|
+
const more = skipped.length - shown.length;
|
|
1240
|
+
const names = shown.join(", ") + (more > 0 ? lang === "zh" ? ` \u7B49 ${more} \u4F4D` : `, and ${more} more` : "");
|
|
1241
|
+
return lang === "zh" ? `
|
|
1242
|
+
|
|
1243
|
+
*\u8DF3\u8FC7\u4E86 ${skipped.length} \u4F4D\u6700\u8FD1 ${RECENT_DAYS} \u5929\u5185\u6DFB\u52A0\u7684\u597D\u53CB\uFF1A${names}\u3002*` : `
|
|
1244
|
+
|
|
1245
|
+
*Skipped ${skipped.length} added in the last ${RECENT_DAYS} days: ${names}.*`;
|
|
1246
|
+
};
|
|
1228
1247
|
const listReply = (rows, skipped, data, title) => {
|
|
1229
1248
|
if (!rows.length) {
|
|
1230
1249
|
return `${title}
|
|
1231
1250
|
|
|
1232
|
-
${lang === "zh" ? "\u6CA1\u6709\u7B26\u5408\u7684\u597D\u53CB\u3002" : "No friends match."}
|
|
1251
|
+
${lang === "zh" ? "\u6CA1\u6709\u7B26\u5408\u7684\u597D\u53CB\u3002" : "No friends match."}${skipLine(skipped)}
|
|
1233
1252
|
|
|
1234
1253
|
${sinceLine(data.historySince, lang)}`;
|
|
1235
1254
|
}
|
|
1236
|
-
const skip = skipped.length ? lang === "zh" ? `
|
|
1237
|
-
|
|
1238
|
-
*\u8DF3\u8FC7\u4E86 ${skipped.length} \u4F4D\u6700\u8FD1 ${RECENT_DAYS} \u5929\u5185\u6DFB\u52A0\u7684\u597D\u53CB\u3002*` : `
|
|
1239
|
-
|
|
1240
|
-
*${skipped.length} friend${skipped.length > 1 ? "s" : ""} added in the last ${RECENT_DAYS} days ${skipped.length > 1 ? "were" : "was"} skipped.*` : "";
|
|
1241
1255
|
return `${title}
|
|
1242
1256
|
|
|
1243
|
-
${friendTable(rows, data.now, lang)}${
|
|
1257
|
+
${friendTable(rows, data.now, lang)}${skipLine(skipped)}
|
|
1244
1258
|
|
|
1245
1259
|
${sinceLine(data.historySince, lang)}`;
|
|
1246
1260
|
};
|
|
@@ -1391,6 +1405,8 @@ ${cands.map((c) => `- ${nameOf(c)}`).join("\n")}`;
|
|
|
1391
1405
|
}
|
|
1392
1406
|
|
|
1393
1407
|
// src/chat.jsx
|
|
1408
|
+
var DK_CMD_HIST_KEY = "beagle.assistant.history";
|
|
1409
|
+
var DK_CMD_HIST_MAX = 50;
|
|
1394
1410
|
function RequestsBlock({ T, requests, onAct }) {
|
|
1395
1411
|
const [acted, setActed] = React.useState({});
|
|
1396
1412
|
const [failed, setFailed] = React.useState({});
|
|
@@ -2792,6 +2808,59 @@ function Conversation({ T, peer, lang, peers, onOpenChat, thread: threadProp, on
|
|
|
2792
2808
|
setSelMode(false);
|
|
2793
2809
|
};
|
|
2794
2810
|
const [draft, setDraft] = React.useState("");
|
|
2811
|
+
const [hist, setHist] = React.useState([]);
|
|
2812
|
+
const histIdx = React.useRef(null);
|
|
2813
|
+
const histStash = React.useRef("");
|
|
2814
|
+
React.useEffect(() => {
|
|
2815
|
+
histIdx.current = null;
|
|
2816
|
+
histStash.current = "";
|
|
2817
|
+
if (!peer.app) {
|
|
2818
|
+
setHist([]);
|
|
2819
|
+
return;
|
|
2820
|
+
}
|
|
2821
|
+
try {
|
|
2822
|
+
setHist(JSON.parse(localStorage.getItem(DK_CMD_HIST_KEY) || "[]"));
|
|
2823
|
+
} catch (e) {
|
|
2824
|
+
setHist([]);
|
|
2825
|
+
}
|
|
2826
|
+
}, [peer.id, peer.app]);
|
|
2827
|
+
const rememberCommand = (text) => {
|
|
2828
|
+
setHist((h) => {
|
|
2829
|
+
const next = (h[h.length - 1] === text ? h : h.concat(text)).slice(-DK_CMD_HIST_MAX);
|
|
2830
|
+
if (peer.app) {
|
|
2831
|
+
try {
|
|
2832
|
+
localStorage.setItem(DK_CMD_HIST_KEY, JSON.stringify(next));
|
|
2833
|
+
} catch (e) {
|
|
2834
|
+
}
|
|
2835
|
+
}
|
|
2836
|
+
return next;
|
|
2837
|
+
});
|
|
2838
|
+
histIdx.current = null;
|
|
2839
|
+
histStash.current = "";
|
|
2840
|
+
};
|
|
2841
|
+
const walkHistory = (dir) => {
|
|
2842
|
+
if (!hist.length)
|
|
2843
|
+
return false;
|
|
2844
|
+
let i = histIdx.current;
|
|
2845
|
+
if (i === null) {
|
|
2846
|
+
if (dir > 0)
|
|
2847
|
+
return false;
|
|
2848
|
+
histStash.current = draft;
|
|
2849
|
+
i = hist.length - 1;
|
|
2850
|
+
} else {
|
|
2851
|
+
i += dir;
|
|
2852
|
+
if (i >= hist.length) {
|
|
2853
|
+
histIdx.current = null;
|
|
2854
|
+
setDraft(histStash.current);
|
|
2855
|
+
return true;
|
|
2856
|
+
}
|
|
2857
|
+
if (i < 0)
|
|
2858
|
+
i = 0;
|
|
2859
|
+
}
|
|
2860
|
+
histIdx.current = i;
|
|
2861
|
+
setDraft(hist[i]);
|
|
2862
|
+
return true;
|
|
2863
|
+
};
|
|
2795
2864
|
const [dragOver, setDragOver] = React.useState(false);
|
|
2796
2865
|
const [sending, setSending] = React.useState(null);
|
|
2797
2866
|
const [theater, setTheater] = React.useState(null);
|
|
@@ -2814,6 +2883,7 @@ function Conversation({ T, peer, lang, peers, onOpenChat, thread: threadProp, on
|
|
|
2814
2883
|
const sendDraft = () => {
|
|
2815
2884
|
if (draft.trim()) {
|
|
2816
2885
|
followScrollRef.current = true;
|
|
2886
|
+
rememberCommand(draft.trim());
|
|
2817
2887
|
onSend(draft);
|
|
2818
2888
|
setDraft("");
|
|
2819
2889
|
requestAnimationFrame(scrollToBottom);
|
|
@@ -2999,11 +3069,19 @@ ${peer.address}`
|
|
|
2999
3069
|
"input",
|
|
3000
3070
|
{
|
|
3001
3071
|
value: draft,
|
|
3002
|
-
onChange: (e) =>
|
|
3072
|
+
onChange: (e) => {
|
|
3073
|
+
histIdx.current = null;
|
|
3074
|
+
setDraft(e.target.value);
|
|
3075
|
+
},
|
|
3003
3076
|
onKeyDown: (e) => {
|
|
3004
3077
|
if (e.key === "Enter" && !e.shiftKey) {
|
|
3005
3078
|
e.preventDefault();
|
|
3006
3079
|
sendDraft();
|
|
3080
|
+
return;
|
|
3081
|
+
}
|
|
3082
|
+
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
3083
|
+
if (walkHistory(e.key === "ArrowUp" ? -1 : 1))
|
|
3084
|
+
e.preventDefault();
|
|
3007
3085
|
}
|
|
3008
3086
|
},
|
|
3009
3087
|
placeholder: phone ? `${T.message}\u2026` : `${T.message} ${peer.alias || shortKey(peer.userId, 6, 4)}\u2026`,
|
package/package.json
CHANGED