@decentnetwork/beagle-ui 0.2.29 → 0.2.31

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.
Files changed (2) hide show
  1. package/dist/beagle-ui.js +37 -7
  2. package/package.json +1 -1
package/dist/beagle-ui.js CHANGED
@@ -1,4 +1,4 @@
1
- export const BEAGLE_UI_VERSION = "0.2.29";
1
+ export const BEAGLE_UI_VERSION = "0.2.31";
2
2
  // src/icons.jsx
3
3
  var ICON_PATHS = {
4
4
  // ---- tab bar (the four must feel like one set) ----
@@ -1335,6 +1335,20 @@ async function loadServicePeers() {
1335
1335
  return service_peers_default;
1336
1336
  }
1337
1337
  }
1338
+ var ASSISTANT_TS_KEY = "beagle.assistant.lastTs";
1339
+ function loadAssistantTs() {
1340
+ try {
1341
+ return Number(localStorage.getItem(ASSISTANT_TS_KEY)) || 0;
1342
+ } catch (e) {
1343
+ return 0;
1344
+ }
1345
+ }
1346
+ function saveAssistantTs(ts) {
1347
+ try {
1348
+ localStorage.setItem(ASSISTANT_TS_KEY, String(ts));
1349
+ } catch (e) {
1350
+ }
1351
+ }
1338
1352
  var ASSISTANT_PEER = {
1339
1353
  id: ASSISTANT_ID,
1340
1354
  userId: ASSISTANT_ID,
@@ -1342,7 +1356,6 @@ var ASSISTANT_PEER = {
1342
1356
  address: "",
1343
1357
  online: true,
1344
1358
  app: true,
1345
- pinned: true,
1346
1359
  agent: false,
1347
1360
  pending: false,
1348
1361
  via: null,
@@ -1447,9 +1460,18 @@ function AssistantPanel({ m, T, lang, onRemove, onAdopt }) {
1447
1460
  }).finally(() => setBusy(false));
1448
1461
  } }, busy ? T.working || "Working\u2026" : label), /* @__PURE__ */ React.createElement("span", { style: { fontSize: 12, color: "var(--faint)" } }, adopt ? lang === "zh" ? "\u53D6\u6D88\u52FE\u9009\u5373\u4FDD\u6301\u4E3A\u597D\u53CB" : "Untick any you want to keep as a friend" : lang === "zh" ? "\u53D6\u6D88\u52FE\u9009\u53EF\u4FDD\u7559" : "Untick anyone you want to keep"))));
1449
1462
  }
1450
- function useAssistant({ lang, T, muted, onToggleMute, sound, flash, setAlert, onReloadFriends }) {
1463
+ function useAssistant({ lang, T, muted, onToggleMute, sound, flash, setAlert, onReloadFriends, onActivity }) {
1451
1464
  const [thread, setThread] = React.useState(() => [{ day: (/* @__PURE__ */ new Date()).toLocaleDateString() }, asMsg("them", helpText(lang))]);
1452
- const append = React.useCallback((...ms) => setThread((t) => t.concat(ms)), []);
1465
+ const bump = React.useCallback(() => {
1466
+ const ts = Date.now();
1467
+ saveAssistantTs(ts);
1468
+ if (onActivity)
1469
+ onActivity(ts);
1470
+ }, [onActivity]);
1471
+ const append = React.useCallback((...ms) => {
1472
+ bump();
1473
+ setThread((t) => t.concat(ms));
1474
+ }, [bump]);
1453
1475
  React.useEffect(() => {
1454
1476
  setThread((t) => t.length === 2 ? [t[0], asMsg("them", helpText(lang))] : t);
1455
1477
  }, [lang]);
@@ -6954,7 +6976,11 @@ function DkApp() {
6954
6976
  sessionStorage.setItem(key, "1");
6955
6977
  window.location.reload();
6956
6978
  }, [me && me.beagleVer]);
6957
- const peers = React.useMemo(() => [ASSISTANT_PEER].concat(data.peers || []), [data.peers]);
6979
+ const [assistantTs, setAssistantTs] = React.useState(loadAssistantTs);
6980
+ const peers = React.useMemo(() => (data.peers || []).concat([Object.assign({}, ASSISTANT_PEER, {
6981
+ lastTs: assistantTs,
6982
+ lastTime: assistantTs ? dkClock(assistantTs) : ""
6983
+ })]), [data.peers, assistantTs]);
6958
6984
  const [pendingAddr, setPendingAddr] = React.useState(() => dkParseDeepLinkAddress());
6959
6985
  React.useEffect(() => {
6960
6986
  const onHash = () => {
@@ -7026,6 +7052,7 @@ function DkApp() {
7026
7052
  T,
7027
7053
  muted: mutedIds,
7028
7054
  onToggleMute,
7055
+ onActivity: setAssistantTs,
7029
7056
  sound: t.alertSound !== false,
7030
7057
  flash: t.alertFlash !== false,
7031
7058
  setAlert: (which, on) => setTweak(which === "sound" ? "alertSound" : "alertFlash", on),
@@ -7112,8 +7139,11 @@ function DkApp() {
7112
7139
  /* @__PURE__ */ React.createElement(Icon, { name: "share", size: 16, stroke: 2, color: "var(--accent)" })
7113
7140
  );
7114
7141
  React.useEffect(() => {
7115
- if (!phone && !activeId && peers.length)
7116
- setActiveId(peers[0].id);
7142
+ if (phone || activeId)
7143
+ return;
7144
+ const first = (peers || []).find((p) => !p.app);
7145
+ if (first)
7146
+ setActiveId(first.id);
7117
7147
  }, [peers, activeId, phone]);
7118
7148
  React.useEffect(() => {
7119
7149
  if (!phone)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentnetwork/beagle-ui",
3
- "version": "0.2.29",
3
+ "version": "0.2.31",
4
4
  "description": "The Beagle chat UI, minus the machine it runs on — shared by the desktop install and the browser build.",
5
5
  "license": "MIT",
6
6
  "type": "module",