Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RNMobile] [Embed block] - Unavailable preview fallback bottom sheet title update #34674

Merged
3 changes: 3 additions & 0 deletions packages/block-library/src/embed/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ const EmbedEdit = ( props ) => {
previewable={ previewable && isProviderPreviewable }
type={ type }
url={ url }
isDefaultEmbedInfo={
! getEmbedInfoByProvider( providerNameSlug )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're already calling this function here:

getEmbedInfoByProvider( providerNameSlug ) || defaultEmbedInfo;

So I'm wondering if we could keep the result on a constant and use it here instead of calling it two times, wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! Thanks for spotting. I will utilize the constant and merge the changes afterward.

}
/>
</View>
</>
Expand Down
22 changes: 16 additions & 6 deletions packages/block-library/src/embed/embed-no-preview.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ import { BlockIcon } from '@wordpress/block-editor';
*/
import styles from './styles.scss';

const EmbedNoPreview = ( { label, icon, isSelected, onPress } ) => {
const EmbedNoPreview = ( {
label,
icon,
isSelected,
onPress,
isDefaultEmbedInfo,
} ) => {
const shouldRequestReview = useRef( false );
const [ isSheetVisible, setIsSheetVisible ] = useState( false );

Expand Down Expand Up @@ -166,11 +172,15 @@ const EmbedNoPreview = ( { label, icon, isSelected, onPress } ) => {
/>
</View>
<Text style={ sheetTitleStyle }>
{ sprintf(
// translators: %s: embed block variant's label e.g: "Twitter".
__( '%s embed block previews are coming soon' ),
label
) }
{ isDefaultEmbedInfo
? __( 'Embed block previews are coming soon' )
: sprintf(
// translators: %s: embed block variant's label e.g: "Twitter".
__(
'%s embed block previews are coming soon'
),
label
) }
</Text>
<Text style={ sheetDescriptionStyle }>
{ comingSoonDescription }
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/embed/embed-preview.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const EmbedPreview = ( {
previewable,
type,
url,
isDefaultEmbedInfo,
} ) => {
const [ isCaptionSelected, setIsCaptionSelected ] = useState( false );
const { locale } = useSelect( blockEditorStore ).getSettings();
Expand Down Expand Up @@ -135,6 +136,7 @@ const EmbedPreview = ( {
icon={ icon }
isSelected={ isSelected }
onPress={ () => setIsCaptionSelected( false ) }
isDefaultEmbedInfo={ isDefaultEmbedInfo }
/>
) }
<BlockCaption
Expand Down