Skip to content

Commit

Permalink
[RNMobile] Hotfix 1.15.2 (#18128)
Browse files Browse the repository at this point in the history
* Force block inserter to re-render on device rotation (#18101)

* Force block inserter to re-render on device rotation

* Dummy

* Revert "Dummy"

This reverts commit 037f076.

* Add left right borders to inner blocks (#18109)

* [Mobile]Remove alignment options from Media & Text until they are fixed (#18112)

* Remove alignment options temporarily

* Dummy commit

* Fix: remove getItemLayout which causes scroll position issue (#18060)

* Fix: Media & Text Loses upload status if post is closed/reopened during the upload (#18137)

* Prevent deleting mediaType on upload progress

* Call onMediaUpdate instead of onSelectMedia

* Dummy commit

* Revert "Dummy commit"

This reverts commit 5ce06d6.

* Limit requestMediaImport calls for only image type

* Update comment

* Dummy commit

* Revert "Dummy commit"

This reverts commit 99584e4.
  • Loading branch information
etoledom authored Oct 30, 2019
1 parent d6ce94c commit d56979d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ export class BlockList extends Component {
ListHeaderComponent={ header }
ListEmptyComponent={ this.renderDefaultBlockAppender }
ListFooterComponent={ withFooter && this.renderBlockListFooter }
getItemLayout={ ( data, index ) => {
return { length: 0, offset: 0, index };
} }
/>

{ renderAppender && blockClientIds.length > 0 &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class InnerBlocks extends Component {
rootClientId={ clientId }
renderAppender={ renderAppender }
withFooter={ false }
isFullyBordered={ true }
/>
) }
</>
Expand Down
20 changes: 17 additions & 3 deletions packages/block-editor/src/components/inserter/menu.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ import { BottomSheet, Icon } from '@wordpress/components';
import styles from './style.scss';

export class InserterMenu extends Component {
constructor() {
super( ...arguments );

this.onLayout = this.onLayout.bind( this );
this.state = {
numberOfColumns: this.calculateNumberOfColumns(),
};
}

componentDidMount() {
this.onOpen();
}
Expand All @@ -47,9 +56,13 @@ export class InserterMenu extends Component {
this.props.hideInsertionPoint();
}

onLayout() {
const numberOfColumns = this.calculateNumberOfColumns();
this.setState( { numberOfColumns } );
}

render() {
const { getStylesFromColorScheme } = this.props;
const numberOfColumns = this.calculateNumberOfColumns();
const bottomPadding = styles.contentBottomPadding;
const modalIconWrapperStyle = getStylesFromColorScheme( styles.modalIconWrapper, styles.modalIconWrapperDark );
const modalIconStyle = getStylesFromColorScheme( styles.modalIcon, styles.modalIconDark );
Expand All @@ -63,10 +76,11 @@ export class InserterMenu extends Component {
hideHeader
>
<FlatList
onLayout={ this.onLayout }
scrollEnabled={ false }
key={ `InserterUI-${ numberOfColumns }` } //re-render when numberOfColumns changes
key={ `InserterUI-${ this.state.numberOfColumns }` } //re-render when numberOfColumns changes
keyboardShouldPersistTaps="always"
numColumns={ numberOfColumns }
numColumns={ this.state.numberOfColumns }
data={ this.props.items }
ItemSeparatorComponent={ () =>
<View style={ styles.rowSeparator } />
Expand Down
16 changes: 9 additions & 7 deletions packages/block-library/src/media-text/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { View } from 'react-native';
import { __, _x } from '@wordpress/i18n';
import {
BlockControls,
BlockVerticalAlignmentToolbar,
// BlockVerticalAlignmentToolbar,
InnerBlocks,
withColors,
} from '@wordpress/block-editor';
Expand Down Expand Up @@ -131,15 +131,16 @@ class MediaTextEdit extends Component {
attributes,
backgroundColor,
setAttributes,
isMobile,
// isMobile,
} = this.props;
const {
isStackedOnMobile,
// isStackedOnMobile,
mediaPosition,
mediaWidth,
verticalAlignment,
} = attributes;
const shouldStack = isStackedOnMobile && isMobile;
const shouldStack = false; // We are temporarily not stacking until we fix alignment buttons
// const shouldStack = isStackedOnMobile && isMobile; // <<< Original line
const temporaryMediaWidth = shouldStack ? 100 : ( this.state.mediaWidth || mediaWidth );
const widthString = `${ temporaryMediaWidth }%`;
const containerStyles = {
Expand All @@ -165,21 +166,22 @@ class MediaTextEdit extends Component {
onClick: () => setAttributes( { mediaPosition: 'right' } ),
} ];

const onVerticalAlignmentChange = ( alignment ) => {
/* const onVerticalAlignmentChange = ( alignment ) => {
setAttributes( { verticalAlignment: alignment } );
};
}; */

return (
<>
<BlockControls>
<Toolbar
controls={ toolbarControls }
/>
{ /* // Temporarily commenting out until alignment functionality is fixed
<BlockVerticalAlignmentToolbar
onChange={ onVerticalAlignmentChange }
value={ verticalAlignment }
isCollapsed={ false }
/>
/> */ }
</BlockControls>
<View style={ containerStyles }>
<View style={ { width: widthString } }>
Expand Down
13 changes: 5 additions & 8 deletions packages/block-library/src/media-text/media-container.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,14 @@ class MediaContainer extends Component {
}

componentDidMount() {
const { mediaId, mediaUrl, onSelectMedia } = this.props;
const { mediaId, mediaUrl, onMediaUpdate, mediaType } = this.props;

if ( mediaId && mediaUrl && ! isURL( mediaUrl ) ) {
if ( mediaUrl.indexOf( 'file:' ) === 0 ) {
requestMediaImport( mediaUrl, ( id, url, type ) => {
if ( mediaUrl.indexOf( 'file:' ) === 0 && mediaType === MEDIA_TYPE_IMAGE ) {
// We don't want to call this for video because it is starting a media upload for the cover url
requestMediaImport( mediaUrl, ( id, url ) => {
if ( url ) {
onSelectMedia( {
media_type: type,
id,
url,
} );
onMediaUpdate( { id, url } );
}
} );
}
Expand Down

0 comments on commit d56979d

Please sign in to comment.