@sanity/assist 2.0.2 → 2.0.3

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.esm.js CHANGED
@@ -6173,11 +6173,12 @@ function PrivateIcon() {
6173
6173
  }
6174
6174
  const ImageContext = createContext({});
6175
6175
  function ImageContextProvider(props) {
6176
- var _a;
6176
+ var _a, _b;
6177
6177
  const {
6178
6178
  schemaType,
6179
6179
  path,
6180
- value
6180
+ value,
6181
+ readOnly
6181
6182
  } = props;
6182
6183
  const assetRef = (_a = value == null ? void 0 : value.asset) == null ? void 0 : _a._ref;
6183
6184
  const [assetRefState, setAssetRefState] = useState(assetRef);
@@ -6196,9 +6197,11 @@ function ImageContextProvider(props) {
6196
6197
  const {
6197
6198
  isSyncing
6198
6199
  } = useSyncState(publicId(documentId), documentSchemaType.name);
6200
+ const router = usePaneRouter();
6201
+ const isShowingOlderRevision = !!((_b = router.params) == null ? void 0 : _b.rev);
6199
6202
  useEffect(() => {
6200
6203
  const descriptionField = getDescriptionFieldOption(schemaType);
6201
- if (assetRef && documentId && descriptionField && assetRef !== assetRefState && !isSyncing) {
6204
+ if (assetRef && documentId && descriptionField && assetRef !== assetRefState && !isSyncing && !isShowingOlderRevision && !readOnly) {
6202
6205
  setAssetRefState(assetRef);
6203
6206
  if (canUseAssist(status)) {
6204
6207
  generateCaption({
@@ -6207,7 +6210,7 @@ function ImageContextProvider(props) {
6207
6210
  });
6208
6211
  }
6209
6212
  }
6210
- }, [schemaType, path, assetRef, assetRefState, documentId, generateCaption, isSyncing, status]);
6213
+ }, [schemaType, path, assetRef, assetRefState, documentId, generateCaption, isSyncing, status, readOnly, isShowingOlderRevision]);
6211
6214
  const context = useMemo(() => {
6212
6215
  const descriptionField = getDescriptionFieldOption(schemaType);
6213
6216
  const imageInstructionField = getImageInstructionFieldOption(schemaType);