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