@ai-matrx/records-ui 0.110.4 → 0.110.6

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/pickers.cjs CHANGED
@@ -48,12 +48,33 @@ var import_design_system17 = require("@ai-matrx/design-system");
48
48
 
49
49
  // src/askOnce.ts
50
50
  var asked = /* @__PURE__ */ new WeakMap();
51
- function askOnce(client, key, ask, freshMs) {
51
+ var byPerson = /* @__PURE__ */ new WeakMap();
52
+ function heldFor(client) {
53
+ const config = client.config;
54
+ const source = config?.dataSource;
55
+ if (source && typeof source === "object" && config?.actor) {
56
+ const who = [config.actor.actor ?? "-", config.actor.user_id ?? "-", config.actor.on_behalf_of ?? "-"].join("|");
57
+ let persons = byPerson.get(source);
58
+ if (!persons) {
59
+ persons = /* @__PURE__ */ new Map();
60
+ byPerson.set(source, persons);
61
+ }
62
+ let held2 = persons.get(who);
63
+ if (!held2) {
64
+ held2 = /* @__PURE__ */ new Map();
65
+ persons.set(who, held2);
66
+ }
67
+ return held2;
68
+ }
52
69
  let held = asked.get(client);
53
70
  if (!held) {
54
71
  held = /* @__PURE__ */ new Map();
55
72
  asked.set(client, held);
56
73
  }
74
+ return held;
75
+ }
76
+ function askOnce(client, key, ask, freshMs) {
77
+ const held = heldFor(client);
57
78
  const now = Date.now();
58
79
  const kept = held.get(key);
59
80
  if (kept && now - kept.at <= freshMs) return kept.answer;
@@ -71,8 +92,7 @@ function askOnce(client, key, ask, freshMs) {
71
92
  return answer;
72
93
  }
73
94
  function forgetAsked(client, prefix) {
74
- const held = asked.get(client);
75
- if (!held) return;
95
+ const held = heldFor(client);
76
96
  for (const key of [...held.keys()]) if (key.startsWith(prefix)) held.delete(key);
77
97
  }
78
98
  var FIELD_OPTIONS_FRESH_MS = 2e3;