@sanity/assist 1.2.10 → 1.2.11

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.js CHANGED
@@ -4311,7 +4311,8 @@ function ImageContextProvider(props) {
4311
4311
  const assetRef = (_a = value == null ? void 0 : value.asset) == null ? void 0 : _a._ref;
4312
4312
  const [assetRefState, setAssetRefState] = react.useState(assetRef);
4313
4313
  const {
4314
- documentId
4314
+ documentId,
4315
+ documentSchemaType
4315
4316
  } = useAssistDocumentContext();
4316
4317
  const {
4317
4318
  config
@@ -4320,16 +4321,19 @@ function ImageContextProvider(props) {
4320
4321
  const {
4321
4322
  generateCaption
4322
4323
  } = useGenerateCaption(apiClient);
4324
+ const {
4325
+ isSyncing
4326
+ } = sanity.useSyncState(publicId(documentId), documentSchemaType.name);
4323
4327
  react.useEffect(() => {
4324
4328
  const captionField = getCaptionFieldOption(schemaType);
4325
- if (assetRef && documentId && captionField && assetRef !== assetRefState) {
4329
+ if (assetRef && documentId && captionField && assetRef !== assetRefState && !isSyncing) {
4326
4330
  setAssetRefState(assetRef);
4327
4331
  generateCaption({
4328
4332
  path: sanity.pathToString([...path, captionField]),
4329
4333
  documentId
4330
4334
  });
4331
4335
  }
4332
- }, [schemaType, path, assetRef, assetRefState, documentId, generateCaption]);
4336
+ }, [schemaType, path, assetRef, assetRefState, documentId, generateCaption, isSyncing]);
4333
4337
  const context = react.useMemo(() => {
4334
4338
  const captionField = getCaptionFieldOption(schemaType);
4335
4339
  return captionField ? {