Skip to content

Commit

Permalink
[RNMobile][Embed Block] Fix loading glitch with resolver resolution a…
Browse files Browse the repository at this point in the history
…pproach (#35798)

* Update logic of fetching calculation

* Update react-native-editor changelog
  • Loading branch information
fluiddot authored and vcanales committed Oct 27, 2021
1 parent 88a152c commit 5866a02
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/block-library/src/embed/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,19 @@ const EmbedEdit = ( props ) => {
( select ) => {
const {
getEmbedPreview,
hasFinishedResolution,
isPreviewEmbedFallback,
isRequestingEmbedPreview,
getThemeSupports,
} = select( coreStore );
if ( ! url ) {
return { fetching: false, cannotEmbed: false };
}

const embedPreview = getEmbedPreview( url );
const hasResolvedEmbedPreview = hasFinishedResolution(
'getEmbedPreview',
[ url ]
);
const previewIsFallback = isPreviewEmbedFallback( url );

// The external oEmbed provider does not exist. We got no type info and no html.
Expand All @@ -108,16 +112,9 @@ const EmbedEdit = ( props ) => {
const validPreview =
!! embedPreview && ! badEmbedProvider && ! wordpressCantEmbed;

// `isRequestingEmbedPreview` is returning false just before an
// `apiFetch` is triggered. We're assuming that a fetch is happening
// if there is an `attributesUrl` set but there is no data in
// `embedPreview` which represents the response returned from the API.
const isFetching =
isRequestingEmbedPreview( url ) || ( url && ! embedPreview );

return {
preview: validPreview ? embedPreview : undefined,
fetching: isFetching,
fetching: ! hasResolvedEmbedPreview,
themeSupportsResponsive: getThemeSupports()[
'responsive-embeds'
],
Expand Down
1 change: 1 addition & 0 deletions packages/react-native-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ For each user feature we should also add a importance categorization label to i

## Unreleased
- [**] Search block - Text and background color support [#35511]
- [*] [Embed Block] Fix loading glitch with resolver resolution approach [#35798]

## 1.64.0
- [*] [Embed block] Fix inline preview cut-off when editing URL [#35321]
Expand Down

0 comments on commit 5866a02

Please sign in to comment.