@ai-matrx/records-ui 0.110.6 → 0.110.8

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.js CHANGED
@@ -6,6 +6,11 @@ import { RecordsProvider as RecordsProvider2, useFields, useRecords, useTable }
6
6
  import { Button as Button8, CreatablePicker } from "@ai-matrx/design-system";
7
7
 
8
8
  // src/askOnce.ts
9
+ import { onTableStructureChanged } from "@ai-matrx/records/core";
10
+ var structureEpoch = 0;
11
+ onTableStructureChanged(() => {
12
+ structureEpoch += 1;
13
+ });
9
14
  var asked = /* @__PURE__ */ new WeakMap();
10
15
  var byPerson = /* @__PURE__ */ new WeakMap();
11
16
  function heldFor(client) {
@@ -36,7 +41,7 @@ function askOnce(client, key, ask, freshMs) {
36
41
  const held = heldFor(client);
37
42
  const now = Date.now();
38
43
  const kept = held.get(key);
39
- if (kept && now - kept.at <= freshMs) return kept.answer;
44
+ if (kept && kept.epoch === structureEpoch && now - kept.at <= freshMs) return kept.answer;
40
45
  const answer = ask().then(
41
46
  (result) => {
42
47
  if (!result.ok) held.delete(key);
@@ -47,14 +52,14 @@ function askOnce(client, key, ask, freshMs) {
47
52
  throw thrown;
48
53
  }
49
54
  );
50
- held.set(key, { at: now, answer });
55
+ held.set(key, { at: now, epoch: structureEpoch, answer });
51
56
  return answer;
52
57
  }
53
58
  function forgetAsked(client, prefix) {
54
59
  const held = heldFor(client);
55
60
  for (const key of [...held.keys()]) if (key.startsWith(prefix)) held.delete(key);
56
61
  }
57
- var FIELD_OPTIONS_FRESH_MS = 2e3;
62
+ var FIELD_OPTIONS_FRESH_MS = 1e4;
58
63
  function fieldOptionsOnce(client, fieldId) {
59
64
  return askOnce(client, `field_options:${fieldId}`, () => client.fieldOptions({ field_id: fieldId }), FIELD_OPTIONS_FRESH_MS);
60
65
  }