composeai 0.1.8 → 0.1.9
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/index.cjs +14 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3393,14 +3393,18 @@ function SlashCommandPlugin({ config, onSubmit }) {
|
|
|
3393
3393
|
config.trigger ?? "/",
|
|
3394
3394
|
{ minLength: 0, maxLength: 32, allowWhitespace: false }
|
|
3395
3395
|
);
|
|
3396
|
+
const itemsRef = react.useRef(config.items);
|
|
3397
|
+
itemsRef.current = config.items;
|
|
3398
|
+
const isAsync = !isSyncItems(config.items);
|
|
3396
3399
|
react.useEffect(() => {
|
|
3397
|
-
|
|
3400
|
+
const items = itemsRef.current;
|
|
3401
|
+
if (isSyncItems(items)) {
|
|
3398
3402
|
setIsLoading(false);
|
|
3399
3403
|
return;
|
|
3400
3404
|
}
|
|
3401
3405
|
let cancelled = false;
|
|
3402
3406
|
setIsLoading(true);
|
|
3403
|
-
Promise.resolve(
|
|
3407
|
+
Promise.resolve(items(query)).then((res) => {
|
|
3404
3408
|
if (cancelled) return;
|
|
3405
3409
|
setAsyncItems(res);
|
|
3406
3410
|
setIsLoading(false);
|
|
@@ -3408,7 +3412,7 @@ function SlashCommandPlugin({ config, onSubmit }) {
|
|
|
3408
3412
|
return () => {
|
|
3409
3413
|
cancelled = true;
|
|
3410
3414
|
};
|
|
3411
|
-
}, [query,
|
|
3415
|
+
}, [query, isAsync]);
|
|
3412
3416
|
const allItems = react.useMemo(() => {
|
|
3413
3417
|
return isSyncItems(config.items) ? config.items : asyncItems ?? [];
|
|
3414
3418
|
}, [config.items, asyncItems]);
|
|
@@ -3599,14 +3603,18 @@ function MentionPlugin({ config }) {
|
|
|
3599
3603
|
maxLength: 32,
|
|
3600
3604
|
allowWhitespace: false
|
|
3601
3605
|
});
|
|
3606
|
+
const itemsRef = react.useRef(config.items);
|
|
3607
|
+
itemsRef.current = config.items;
|
|
3608
|
+
const isAsync = !isSyncItems2(config.items);
|
|
3602
3609
|
react.useEffect(() => {
|
|
3603
|
-
|
|
3610
|
+
const items = itemsRef.current;
|
|
3611
|
+
if (isSyncItems2(items)) {
|
|
3604
3612
|
setIsLoading(false);
|
|
3605
3613
|
return;
|
|
3606
3614
|
}
|
|
3607
3615
|
let cancelled = false;
|
|
3608
3616
|
setIsLoading(true);
|
|
3609
|
-
Promise.resolve(
|
|
3617
|
+
Promise.resolve(items(query)).then((res) => {
|
|
3610
3618
|
if (cancelled) return;
|
|
3611
3619
|
setAsyncItems(res);
|
|
3612
3620
|
setIsLoading(false);
|
|
@@ -3614,7 +3622,7 @@ function MentionPlugin({ config }) {
|
|
|
3614
3622
|
return () => {
|
|
3615
3623
|
cancelled = true;
|
|
3616
3624
|
};
|
|
3617
|
-
}, [query,
|
|
3625
|
+
}, [query, isAsync]);
|
|
3618
3626
|
const allItems = react.useMemo(() => {
|
|
3619
3627
|
return isSyncItems2(config.items) ? config.items : asyncItems ?? [];
|
|
3620
3628
|
}, [config.items, asyncItems]);
|