diff --git a/packages/block-editor/src/components/story-update-progress/README.md b/packages/block-editor/src/components/block-media-update-progress/README.md similarity index 87% rename from packages/block-editor/src/components/story-update-progress/README.md rename to packages/block-editor/src/components/block-media-update-progress/README.md index 75b87b0f4485ad..2f9844bc7a22be 100644 --- a/packages/block-editor/src/components/story-update-progress/README.md +++ b/packages/block-editor/src/components/block-media-update-progress/README.md @@ -1,7 +1,7 @@ -StoryUpdateProgress +BlockMediaUpdateProgress =================== -`StoryUpdateProgress` shows a progress bar while the media files associated with a Story block are being saved and uploaded +`BlockMediaUpdateProgress` shows a progress bar while the media files associated with a media-containing block are being saved first and uploaded later ## Usage @@ -10,12 +10,12 @@ Usage example ```jsx import { ImageBackground, Text, View } from 'react-native'; import { - StoryUpdateProgress, + BlockMediaUpdateProgress, } from '@wordpress/block-editor'; -function StoryProgress( { url, id } ) { +function BlockUpdatingProgress( { url, id } ) { return ( - { return ( diff --git a/packages/block-editor/src/components/story-update-progress/index.native.js b/packages/block-editor/src/components/block-media-update-progress/index.native.js similarity index 87% rename from packages/block-editor/src/components/story-update-progress/index.native.js rename to packages/block-editor/src/components/block-media-update-progress/index.native.js index 0c370429c507e9..0ff813f88c4721 100644 --- a/packages/block-editor/src/components/story-update-progress/index.native.js +++ b/packages/block-editor/src/components/block-media-update-progress/index.native.js @@ -19,19 +19,19 @@ import { */ import styles from './styles.scss'; -export const STORY_UPLOAD_STATE_UPLOADING = 1; -export const STORY_UPLOAD_STATE_SUCCEEDED = 2; -export const STORY_UPLOAD_STATE_FAILED = 3; -export const STORY_UPLOAD_STATE_RESET = 4; +export const MEDIA_UPLOAD_STATE_UPLOADING = 1; +export const MEDIA_UPLOAD_STATE_SUCCEEDED = 2; +export const MEDIA_UPLOAD_STATE_FAILED = 3; +export const MEDIA_UPLOAD_STATE_RESET = 4; export const MEDIA_SAVE_STATE_SAVING = 5; export const MEDIA_SAVE_STATE_SUCCEEDED = 6; export const MEDIA_SAVE_STATE_FAILED = 7; export const MEDIA_SAVE_STATE_RESET = 8; -export const STORY_SAVE_STATE_RESULT = 9; +export const MEDIA_SAVE_FINAL_STATE_RESULT = 9; export const MEDIA_SAVE_MEDIAMODEL_CREATED = 10; -export class StoryUpdateProgress extends React.Component { +export class BlockMediaUpdateProgress extends React.Component { constructor( props ) { super( props ); @@ -79,16 +79,16 @@ export class StoryUpdateProgress extends React.Component { } switch ( payload.state ) { - case STORY_UPLOAD_STATE_UPLOADING: + case MEDIA_UPLOAD_STATE_UPLOADING: this.updateMediaUploadProgress( payload ); break; - case STORY_UPLOAD_STATE_SUCCEEDED: + case MEDIA_UPLOAD_STATE_SUCCEEDED: this.finishMediaUploadWithSuccess( payload ); break; - case STORY_UPLOAD_STATE_FAILED: + case MEDIA_UPLOAD_STATE_FAILED: this.finishMediaUploadWithFailure( payload ); break; - case STORY_UPLOAD_STATE_RESET: + case MEDIA_UPLOAD_STATE_RESET: this.mediaUploadStateReset( payload ); break; } @@ -117,8 +117,8 @@ export class StoryUpdateProgress extends React.Component { case MEDIA_SAVE_STATE_RESET: this.mediaSaveStateReset( payload ); break; - case STORY_SAVE_STATE_RESULT: - this.storySaveResult( payload ); + case MEDIA_SAVE_FINAL_STATE_RESULT: + this.finalSaveResult( payload ); break; case MEDIA_SAVE_MEDIAMODEL_CREATED: this.mediaModelCreated( payload ); @@ -126,7 +126,7 @@ export class StoryUpdateProgress extends React.Component { } } - // ---- Story (media) save actions + // ---- Block media save actions updateMediaSaveProgress( payload ) { this.setState( { progress: payload.progress, @@ -149,8 +149,8 @@ export class StoryUpdateProgress extends React.Component { finishMediaSaveWithFailure( payload ) { this.setState( { isSaveInProgress: false, isSaveFailed: true } ); - if ( this.props.onFinishMediaUploadWithFailure ) { - this.props.onFinishMediaUploadWithFailure( payload ); + if ( this.props.onFinishMediaSaveWithFailure ) { + this.props.onFinishMediaSaveWithFailure( payload ); } } @@ -161,7 +161,7 @@ export class StoryUpdateProgress extends React.Component { } } - storySaveResult( payload ) { + finalSaveResult( payload ) { this.setState( { progress: payload.progress, isUploadInProgress: false, @@ -169,8 +169,8 @@ export class StoryUpdateProgress extends React.Component { isSaveInProgress: false, isSaveFailed: ! payload.success, } ); - if ( this.props.onStorySaveResult ) { - this.props.onStorySaveResult( payload ); + if ( this.props.onFinalSaveResult ) { + this.props.onFinalSaveResult( payload ); } } @@ -186,7 +186,7 @@ export class StoryUpdateProgress extends React.Component { } } - // ---- Story upload actions + // ---- Block media upload actions updateMediaUploadProgress( payload ) { this.setState( { progress: payload.progress, @@ -268,7 +268,7 @@ export class StoryUpdateProgress extends React.Component { const progress = this.state.progress * 100; // eslint-disable-next-line @wordpress/i18n-no-collapsible-whitespace const retryMessage = __( - 'Failed to save Story.\nPlease tap for options.' + 'Failed to save files.\nPlease tap for options.' ); return ( @@ -290,4 +290,4 @@ export class StoryUpdateProgress extends React.Component { } } -export default StoryUpdateProgress; +export default BlockMediaUpdateProgress; diff --git a/packages/block-editor/src/components/story-update-progress/styles.native.scss b/packages/block-editor/src/components/block-media-update-progress/styles.native.scss similarity index 100% rename from packages/block-editor/src/components/story-update-progress/styles.native.scss rename to packages/block-editor/src/components/block-media-update-progress/styles.native.scss diff --git a/packages/block-editor/src/components/index.native.js b/packages/block-editor/src/components/index.native.js index 8f8ab518934b4c..2245d16a1511ba 100644 --- a/packages/block-editor/src/components/index.native.js +++ b/packages/block-editor/src/components/index.native.js @@ -28,7 +28,7 @@ export { MEDIA_TYPE_VIDEO, } from './media-upload'; export { default as MediaUploadProgress } from './media-upload-progress'; -export { default as StoryUpdateProgress } from './story-update-progress'; +export { default as BlockMediaUpdateProgress } from './block-media-update-progress'; export { default as URLInput } from './url-input'; export { default as BlockInvalidWarning } from './block-list/block-invalid-warning'; export { default as BlockCaption } from './block-caption'; diff --git a/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/GutenbergBridgeJS2Parent.java b/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/GutenbergBridgeJS2Parent.java index df5d2d3c8fd162..89cb3ccf3b5adc 100644 --- a/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/GutenbergBridgeJS2Parent.java +++ b/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/GutenbergBridgeJS2Parent.java @@ -34,12 +34,12 @@ interface MediaUploadEventEmitter { void onMediaFileUploadFailed(int mediaId); } - interface StorySaveEventEmitter { + interface MediaSaveEventEmitter { void onSaveMediaFileClear(String mediaId); void onMediaFileSaveProgress(String mediaId, float progress); void onMediaFileSaveSucceeded(String mediaId, String mediaUrl); void onMediaFileSaveFailed(String mediaId); - void onStorySaveResult(String storyFirstMediaId, boolean success); + void onMediaCollectionSaveResult(String firstMediaIdInCollection, boolean success); void onMediaModelCreatedForFile(final String oldId, final String newId, final String oldUrl); } @@ -47,8 +47,8 @@ interface ReplaceUnsupportedBlockCallback { void replaceUnsupportedBlock(String content, String blockId); } - interface ReplaceStoryEditedBlockCallback { - void replaceStoryBlock(String mediaFiles, String blockId); + interface ReplaceMediaFilesEditedBlockCallback { + void replaceMediaFilesEditedBlock(String mediaFiles, String blockId); } interface StarterPageTemplatesTooltipShownCallback { @@ -135,7 +135,7 @@ public static GutenbergUserEvent getEnum(String eventName) { void mediaUploadSync(MediaSelectedCallback mediaSelectedCallback); - void storySaveSync(MediaSelectedCallback mediaSelectedCallback); + void mediaSaveSync(MediaSelectedCallback mediaSelectedCallback); void requestImageFailedRetryDialog(int mediaId); @@ -171,7 +171,7 @@ void gutenbergDidRequestUnsupportedBlockFallback(ReplaceUnsupportedBlockCallback void requestStarterPageTemplatesTooltipShown(StarterPageTemplatesTooltipShownCallback starterPageTemplatesTooltipShownCallback); - void requestStoryCreatorLoad(ReplaceStoryEditedBlockCallback replaceStoryEditedBlockCallback, + void requestMediaFilesEditorLoad(ReplaceMediaFilesEditedBlockCallback replaceMediaFilesEditedBlockCallback, ReadableArray mediaFiles, String blockId ); diff --git a/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/RNReactNativeGutenbergBridgeModule.java b/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/RNReactNativeGutenbergBridgeModule.java index e589842a33a3a6..e64c9d357c2be2 100644 --- a/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/RNReactNativeGutenbergBridgeModule.java +++ b/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/RNReactNativeGutenbergBridgeModule.java @@ -55,7 +55,7 @@ public class RNReactNativeGutenbergBridgeModule extends ReactContextBaseJavaModu public static final String MAP_KEY_MEDIA_FILE_UPLOAD_MEDIA_TYPE = "mediaType"; private static final String MAP_KEY_THEME_UPDATE_COLORS = "colors"; private static final String MAP_KEY_THEME_UPDATE_GRADIENTS = "gradients"; - public static final String MAP_KEY_STORY_SAVE_RESULT = "storySaveResult"; + public static final String MAP_KEY_MEDIA_FINAL_SAVE_RESULT = "mediaFinalSaveResult"; private static final String MAP_KEY_IS_PREFERRED_COLOR_SCHEME_DARK = "isPreferredColorSchemeDark"; @@ -198,8 +198,8 @@ public void mediaUploadSync() { } @ReactMethod - public void storySaveSync() { - mGutenbergBridgeJS2Parent.storySaveSync(getNewMediaSelectedCallback(true,null)); + public void mediaSaveSync() { + mGutenbergBridgeJS2Parent.mediaSaveSync(getNewMediaSelectedCallback(true,null)); } @ReactMethod @@ -228,8 +228,8 @@ public void requestMediaEditor(String mediaUrl, final Callback onUploadMediaSele } @ReactMethod - public void requestStoryCreatorLoad(ReadableArray mediaFiles, String blockId) { - mGutenbergBridgeJS2Parent.requestStoryCreatorLoad((savedMediaFiles, savedBlockId) -> + public void requestMediaFilesEditorLoad(ReadableArray mediaFiles, String blockId) { + mGutenbergBridgeJS2Parent.requestMediaFilesEditorLoad((savedMediaFiles, savedBlockId) -> replaceBlock(savedMediaFiles, savedBlockId), mediaFiles, blockId); } diff --git a/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/DeferredEventEmitter.java b/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/DeferredEventEmitter.java index 54548042e8a0e7..98b473322a32f4 100644 --- a/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/DeferredEventEmitter.java +++ b/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/DeferredEventEmitter.java @@ -9,7 +9,7 @@ import com.facebook.react.bridge.WritableNativeMap; import org.wordpress.mobile.ReactNativeGutenbergBridge.GutenbergBridgeJS2Parent.MediaUploadEventEmitter; -import org.wordpress.mobile.ReactNativeGutenbergBridge.GutenbergBridgeJS2Parent.StorySaveEventEmitter; +import org.wordpress.mobile.ReactNativeGutenbergBridge.GutenbergBridgeJS2Parent.MediaSaveEventEmitter; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; @@ -17,9 +17,9 @@ import static org.wordpress.mobile.ReactNativeGutenbergBridge.RNReactNativeGutenbergBridgeModule.MAP_KEY_MEDIA_FILE_UPLOAD_MEDIA_ID; import static org.wordpress.mobile.ReactNativeGutenbergBridge.RNReactNativeGutenbergBridgeModule.MAP_KEY_MEDIA_FILE_UPLOAD_MEDIA_NEW_ID; import static org.wordpress.mobile.ReactNativeGutenbergBridge.RNReactNativeGutenbergBridgeModule.MAP_KEY_MEDIA_FILE_UPLOAD_MEDIA_URL; -import static org.wordpress.mobile.ReactNativeGutenbergBridge.RNReactNativeGutenbergBridgeModule.MAP_KEY_STORY_SAVE_RESULT; +import static org.wordpress.mobile.ReactNativeGutenbergBridge.RNReactNativeGutenbergBridgeModule.MAP_KEY_MEDIA_FINAL_SAVE_RESULT; -public class DeferredEventEmitter implements MediaUploadEventEmitter, StorySaveEventEmitter { +public class DeferredEventEmitter implements MediaUploadEventEmitter, MediaSaveEventEmitter { public interface JSEventEmitter { void emitToJS(String eventName, @Nullable WritableMap data); } @@ -33,15 +33,15 @@ public interface JSEventEmitter { private static final int MEDIA_SAVE_STATE_SUCCEEDED = 6; private static final int MEDIA_SAVE_STATE_FAILED = 7; private static final int MEDIA_SAVE_STATE_RESET = 8; - private static final int STORY_SAVE_STATE_RESULT = 9; + private static final int MEDIA_SAVE_FINAL_STATE_RESULT = 9; private static final int MEDIA_SAVE_MEDIAMODEL_CREATED = 10; private static final String EVENT_NAME_MEDIA_UPLOAD = "mediaUpload"; private static final String EVENT_NAME_MEDIA_SAVE = "mediaSave"; - private static final String MAP_KEY_MEDIA_FILE_UPLOAD_STATE = "state"; - private static final String MAP_KEY_MEDIA_FILE_UPLOAD_MEDIA_PROGRESS = "progress"; - private static final String MAP_KEY_MEDIA_FILE_UPLOAD_MEDIA_SERVER_ID = "mediaServerId"; + private static final String MAP_KEY_MEDIA_FILE_STATE = "state"; + private static final String MAP_KEY_MEDIA_FILE_MEDIA_ACTION_PROGRESS = "progress"; + private static final String MAP_KEY_MEDIA_FILE_MEDIA_SERVER_ID = "mediaServerId"; private static final String MAP_KEY_UPDATE_CAPABILITIES = "updateCapabilities"; @@ -97,12 +97,12 @@ private void setMediaFileUploadDataInJS(int state, int mediaId, String mediaUrl, private void setMediaFileUploadDataInJS(int state, int mediaId, String mediaUrl, float progress, int mediaServerId) { WritableMap writableMap = new WritableNativeMap(); - writableMap.putInt(MAP_KEY_MEDIA_FILE_UPLOAD_STATE, state); + writableMap.putInt(MAP_KEY_MEDIA_FILE_STATE, state); writableMap.putInt(MAP_KEY_MEDIA_FILE_UPLOAD_MEDIA_ID, mediaId); writableMap.putString(MAP_KEY_MEDIA_FILE_UPLOAD_MEDIA_URL, mediaUrl); - writableMap.putDouble(MAP_KEY_MEDIA_FILE_UPLOAD_MEDIA_PROGRESS, progress); + writableMap.putDouble(MAP_KEY_MEDIA_FILE_MEDIA_ACTION_PROGRESS, progress); if (mediaServerId != MEDIA_SERVER_ID_UNKNOWN) { - writableMap.putInt(MAP_KEY_MEDIA_FILE_UPLOAD_MEDIA_SERVER_ID, mediaServerId); + writableMap.putInt(MAP_KEY_MEDIA_FILE_MEDIA_SERVER_ID, mediaServerId); } if (isCriticalMessage(state)) { queueActionToJS(EVENT_NAME_MEDIA_UPLOAD, writableMap); @@ -111,12 +111,12 @@ private void setMediaFileUploadDataInJS(int state, int mediaId, String mediaUrl, } } - private void setStorySaveDataInJS(int state, String mediaId, String mediaUrl, float progress) { + private void setMediaSaveResultDataInJS(int state, String mediaId, String mediaUrl, float progress) { WritableMap writableMap = new WritableNativeMap(); - writableMap.putInt(MAP_KEY_MEDIA_FILE_UPLOAD_STATE, state); + writableMap.putInt(MAP_KEY_MEDIA_FILE_STATE, state); writableMap.putString(MAP_KEY_MEDIA_FILE_UPLOAD_MEDIA_ID, mediaId); writableMap.putString(MAP_KEY_MEDIA_FILE_UPLOAD_MEDIA_URL, mediaUrl); - writableMap.putDouble(MAP_KEY_MEDIA_FILE_UPLOAD_MEDIA_PROGRESS, progress); + writableMap.putDouble(MAP_KEY_MEDIA_FILE_MEDIA_ACTION_PROGRESS, progress); if (isCriticalMessage(state)) { queueActionToJS(EVENT_NAME_MEDIA_SAVE, writableMap); } else { @@ -124,12 +124,12 @@ private void setStorySaveDataInJS(int state, String mediaId, String mediaUrl, fl } } - private void setStorySaveDataInJS(int state, String mediaId, boolean success, float progress) { + private void setMediaSaveResultDataInJS(int state, String mediaId, boolean success, float progress) { WritableMap writableMap = new WritableNativeMap(); - writableMap.putInt(MAP_KEY_MEDIA_FILE_UPLOAD_STATE, state); + writableMap.putInt(MAP_KEY_MEDIA_FILE_STATE, state); writableMap.putString(MAP_KEY_MEDIA_FILE_UPLOAD_MEDIA_ID, mediaId); - writableMap.putBoolean(MAP_KEY_STORY_SAVE_RESULT, success); - writableMap.putDouble(MAP_KEY_MEDIA_FILE_UPLOAD_MEDIA_PROGRESS, progress); + writableMap.putBoolean(MAP_KEY_MEDIA_FINAL_SAVE_RESULT, success); + writableMap.putDouble(MAP_KEY_MEDIA_FILE_MEDIA_ACTION_PROGRESS, progress); if (isCriticalMessage(state)) { queueActionToJS(EVENT_NAME_MEDIA_SAVE, writableMap); } else { @@ -163,35 +163,35 @@ public void onMediaFileUploadFailed(int mediaId) { setMediaFileUploadDataInJS(MEDIA_UPLOAD_STATE_FAILED, mediaId, null, 0); } - // Story save events emitter + // Media file save events emitter @Override public void onSaveMediaFileClear(String mediaId) { - setStorySaveDataInJS(MEDIA_SAVE_STATE_RESET, mediaId, null, 0); + setMediaSaveResultDataInJS(MEDIA_SAVE_STATE_RESET, mediaId, null, 0); } @Override public void onMediaFileSaveProgress(String mediaId, float progress) { - setStorySaveDataInJS(MEDIA_SAVE_STATE_SAVING, mediaId, null, progress); + setMediaSaveResultDataInJS(MEDIA_SAVE_STATE_SAVING, mediaId, null, progress); } @Override public void onMediaFileSaveSucceeded(String mediaId, String mediaUrl) { - setStorySaveDataInJS(MEDIA_SAVE_STATE_SUCCEEDED, mediaId, mediaUrl, 1); + setMediaSaveResultDataInJS(MEDIA_SAVE_STATE_SUCCEEDED, mediaId, mediaUrl, 1); } @Override public void onMediaFileSaveFailed(String mediaId) { - setStorySaveDataInJS(MEDIA_SAVE_STATE_FAILED, mediaId, null, 0); + setMediaSaveResultDataInJS(MEDIA_SAVE_STATE_FAILED, mediaId, null, 0); } @Override - public void onStorySaveResult(String storyFirstMediaId, boolean success) { - setStorySaveDataInJS(STORY_SAVE_STATE_RESULT, storyFirstMediaId, success, success ? 1 : 0); + public void onMediaCollectionSaveResult(String firstMediaIdInCollection, boolean success) { + setMediaSaveResultDataInJS(MEDIA_SAVE_FINAL_STATE_RESULT, firstMediaIdInCollection, success, success ? 1 : 0); } @Override public void onMediaModelCreatedForFile(String oldId, String newId, String oldUrl) { WritableMap writableMap = new WritableNativeMap(); - writableMap.putInt(MAP_KEY_MEDIA_FILE_UPLOAD_STATE, MEDIA_SAVE_MEDIAMODEL_CREATED); + writableMap.putInt(MAP_KEY_MEDIA_FILE_STATE, MEDIA_SAVE_MEDIAMODEL_CREATED); writableMap.putString(MAP_KEY_MEDIA_FILE_UPLOAD_MEDIA_ID, oldId); writableMap.putString(MAP_KEY_MEDIA_FILE_UPLOAD_MEDIA_NEW_ID, newId); writableMap.putString(MAP_KEY_MEDIA_FILE_UPLOAD_MEDIA_URL, oldUrl); diff --git a/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/WPAndroidGlueCode.java b/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/WPAndroidGlueCode.java index 980c653aa6e31f..9c61321afd67fc 100644 --- a/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/WPAndroidGlueCode.java +++ b/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/WPAndroidGlueCode.java @@ -49,7 +49,7 @@ import org.wordpress.mobile.ReactNativeGutenbergBridge.GutenbergBridgeJS2Parent; import org.wordpress.mobile.ReactNativeGutenbergBridge.GutenbergBridgeJS2Parent.GutenbergUserEvent; import org.wordpress.mobile.ReactNativeGutenbergBridge.GutenbergBridgeJS2Parent.MediaSelectedCallback; -import org.wordpress.mobile.ReactNativeGutenbergBridge.GutenbergBridgeJS2Parent.ReplaceStoryEditedBlockCallback; +import org.wordpress.mobile.ReactNativeGutenbergBridge.GutenbergBridgeJS2Parent.ReplaceMediaFilesEditedBlockCallback; import org.wordpress.mobile.ReactNativeGutenbergBridge.GutenbergBridgeJS2Parent.ReplaceUnsupportedBlockCallback; import org.wordpress.mobile.ReactNativeGutenbergBridge.RNMedia; import org.wordpress.mobile.ReactNativeGutenbergBridge.RNReactNativeGutenbergBridgePackage; @@ -83,8 +83,8 @@ public class WPAndroidGlueCode { private boolean mAppendsMultipleSelectedToSiblingBlocks = false; private OnMediaLibraryButtonListener mOnMediaLibraryButtonListener; - private OnReattachQueryListener mOnReattachQueryListener; - private OnStorySavingReattachQueryListener mOnStorySavingReattachQueryListener; + private OnReattachMediaUploadQueryListener mOnReattachMediaUploadQueryListener; + private OnReattachMediaSavingQueryListener mOnReattachMediaSavingQueryListener; private OnEditorMountListener mOnEditorMountListener; private OnEditorAutosaveListener mOnEditorAutosaveListener; private OnImageFullscreenPreviewListener mOnImageFullscreenPreviewListener; @@ -94,8 +94,8 @@ public class WPAndroidGlueCode { private OnGutenbergDidSendButtonPressedActionListener mOnGutenbergDidSendButtonPressedActionListener; private ReplaceUnsupportedBlockCallback mReplaceUnsupportedBlockCallback; private OnStarterPageTemplatesTooltipShownEventListener mOnStarterPageTemplatesTooltipShownListener; - private OnStoryCreatorLoadRequestListener mOnStoryCreatorLoadRequestListener; - private ReplaceStoryEditedBlockCallback mReplaceStoryEditedBlockCallback; + private OnMediaFilesEditorLoadRequestListener mOnMediaFilesEditorLoadRequestListener; + private ReplaceMediaFilesEditedBlockCallback mReplaceMediaFilesEditedBlockCallback; private boolean mIsEditorMounted; private String mContentHtml = ""; @@ -150,20 +150,20 @@ public interface OnMediaLibraryButtonListener { void onOtherMediaButtonClicked(String mediaSource, boolean allowMultipleSelection); } - public interface OnStoryCreatorLoadRequestListener { - void onRequestStoryCreatorLoad(ArrayList mediaFiles, String blockId); + public interface OnMediaFilesEditorLoadRequestListener { + void onRequestMediaFilesEditorLoad(ArrayList mediaFiles, String blockId); } public interface OnImageFullscreenPreviewListener { void onImageFullscreenPreviewClicked(String mediaUrl); } - public interface OnReattachQueryListener { + public interface OnReattachMediaUploadQueryListener { void onQueryCurrentProgressForUploadingMedia(); } - public interface OnStorySavingReattachQueryListener { - void onQueryCurrentProgressForStoryMediaSaving(); + public interface OnReattachMediaSavingQueryListener { + void onQueryCurrentProgressForSavingMedia(); } public interface OnEditorMountListener { @@ -278,13 +278,13 @@ public void requestMediaImport(String url, MediaSelectedCallback mediaSelectedCa @Override public void mediaUploadSync(MediaSelectedCallback mediaSelectedCallback) { mMediaSelectedCallback = mediaSelectedCallback; - mOnReattachQueryListener.onQueryCurrentProgressForUploadingMedia(); + mOnReattachMediaUploadQueryListener.onQueryCurrentProgressForUploadingMedia(); } @Override - public void storySaveSync(MediaSelectedCallback mediaSelectedCallback) { + public void mediaSaveSync(MediaSelectedCallback mediaSelectedCallback) { mMediaSelectedCallback = mediaSelectedCallback; - mOnStorySavingReattachQueryListener.onQueryCurrentProgressForStoryMediaSaving(); + mOnReattachMediaSavingQueryListener.onQueryCurrentProgressForSavingMedia(); } @Override @@ -418,13 +418,13 @@ public void requestStarterPageTemplatesTooltipShown(StarterPageTemplatesTooltipS } @Override - public void requestStoryCreatorLoad( - ReplaceStoryEditedBlockCallback replaceStoryEditedBlockCallback, + public void requestMediaFilesEditorLoad( + ReplaceMediaFilesEditedBlockCallback replaceMediaFilesEditedBlockCallback, ReadableArray mediaFiles, String blockId ) { - mReplaceStoryEditedBlockCallback = replaceStoryEditedBlockCallback; - mOnStoryCreatorLoadRequestListener.onRequestStoryCreatorLoad(mediaFiles.toArrayList(), blockId); + mReplaceMediaFilesEditedBlockCallback = replaceMediaFilesEditedBlockCallback; + mOnMediaFilesEditorLoadRequestListener.onRequestMediaFilesEditorLoad(mediaFiles.toArrayList(), blockId); } }, mIsDarkMode); @@ -489,8 +489,8 @@ public void onCreateView(Context initContext, public void attachToContainer(ViewGroup viewGroup, OnMediaLibraryButtonListener onMediaLibraryButtonListener, - OnReattachQueryListener onReattachQueryListener, - OnStorySavingReattachQueryListener onStorySavingReattachQueryListener, + OnReattachMediaUploadQueryListener onReattachMediaUploadQueryListener, + OnReattachMediaSavingQueryListener onReattachMediaSavingQueryListener, OnEditorMountListener onEditorMountListener, OnEditorAutosaveListener onEditorAutosaveListener, OnAuthHeaderRequestedListener onAuthHeaderRequestedListener, @@ -502,14 +502,14 @@ public void attachToContainer(ViewGroup viewGroup, OnGutenbergDidSendButtonPressedActionListener onGutenbergDidSendButtonPressedActionListener, AddMentionUtil addMentionUtil, OnStarterPageTemplatesTooltipShownEventListener onStarterPageTemplatesTooltipListener, - OnStoryCreatorLoadRequestListener onStoryCreatorLoadRequestListener, + OnMediaFilesEditorLoadRequestListener onMediaFilesEditorLoadRequestListener, boolean isDarkMode) { MutableContextWrapper contextWrapper = (MutableContextWrapper) mReactRootView.getContext(); contextWrapper.setBaseContext(viewGroup.getContext()); mOnMediaLibraryButtonListener = onMediaLibraryButtonListener; - mOnReattachQueryListener = onReattachQueryListener; - mOnStorySavingReattachQueryListener = onStorySavingReattachQueryListener; + mOnReattachMediaUploadQueryListener = onReattachMediaUploadQueryListener; + mOnReattachMediaSavingQueryListener = onReattachMediaSavingQueryListener; mOnEditorMountListener = onEditorMountListener; mOnEditorAutosaveListener = onEditorAutosaveListener; mRequestExecutor = fetchExecutor; @@ -520,7 +520,7 @@ public void attachToContainer(ViewGroup viewGroup, mOnGutenbergDidSendButtonPressedActionListener = onGutenbergDidSendButtonPressedActionListener; mAddMentionUtil = addMentionUtil; mOnStarterPageTemplatesTooltipShownListener = onStarterPageTemplatesTooltipListener; - mOnStoryCreatorLoadRequestListener = onStoryCreatorLoadRequestListener; + mOnMediaFilesEditorLoadRequestListener = onMediaFilesEditorLoadRequestListener; sAddCookiesInterceptor.setOnAuthHeaderRequestedListener(onAuthHeaderRequestedListener); @@ -896,8 +896,8 @@ public void mediaFileSaveSucceeded(final String mediaId, final String mediaUrl) mDeferredEventEmitter.onMediaFileSaveSucceeded(mediaId, mediaUrl); } - public void storySaveResult(final String storyFirstMediaId, final boolean success) { - mDeferredEventEmitter.onStorySaveResult(storyFirstMediaId, success); + public void mediaCollectionFinalSaveResult(final String blockFirstMediaId, final boolean success) { + mDeferredEventEmitter.onMediaCollectionSaveResult(blockFirstMediaId, success); } public void mediaModelCreatedForFile(final String oldId, final String newId, final String oldUrl) { @@ -911,10 +911,10 @@ public void replaceUnsupportedBlock(String content, String blockId) { } } - public void replaceStoryEditedBlock(String mediaFiles, String blockId) { - if (mReplaceStoryEditedBlockCallback != null) { - mReplaceStoryEditedBlockCallback.replaceStoryBlock(mediaFiles, blockId); - mReplaceStoryEditedBlockCallback = null; + public void replaceMediaFilesEditedBlock(String mediaFiles, String blockId) { + if (mReplaceMediaFilesEditedBlockCallback != null) { + mReplaceMediaFilesEditedBlockCallback.replaceMediaFilesEditedBlock(mediaFiles, blockId); + mReplaceMediaFilesEditedBlockCallback = null; } } diff --git a/packages/react-native-bridge/index.js b/packages/react-native-bridge/index.js index b594debfc0e93a..c411f06dfd4716 100644 --- a/packages/react-native-bridge/index.js +++ b/packages/react-native-bridge/index.js @@ -179,8 +179,8 @@ export function mediaUploadSync() { return RNReactNativeGutenbergBridge.mediaUploadSync(); } -export function storySaveSync() { - return RNReactNativeGutenbergBridge.storySaveSync(); +export function mediaSaveSync() { + return RNReactNativeGutenbergBridge.mediaSaveSync(); } export function requestImageFailedRetryDialog( mediaId ) { @@ -252,8 +252,8 @@ export function setStarterPageTemplatesTooltipShown( tooltipShown ) { ); } -export function requestStoryCreatorLoad( mediaFiles, blockClientId ) { - return RNReactNativeGutenbergBridge.requestStoryCreatorLoad( +export function requestMediaFilesEditorLoad( mediaFiles, blockClientId ) { + return RNReactNativeGutenbergBridge.requestMediaFilesEditorLoad( mediaFiles, blockClientId ); diff --git a/packages/react-native-bridge/ios/RNReactNativeGutenbergBridge.m b/packages/react-native-bridge/ios/RNReactNativeGutenbergBridge.m index 618c1c73937f8b..46b813cfc660de 100644 --- a/packages/react-native-bridge/ios/RNReactNativeGutenbergBridge.m +++ b/packages/react-native-bridge/ios/RNReactNativeGutenbergBridge.m @@ -23,7 +23,7 @@ @interface RCT_EXTERN_MODULE(RNReactNativeGutenbergBridge, NSObject) RCT_EXTERN_METHOD(addMention:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)rejecter) RCT_EXTERN_METHOD(requestStarterPageTemplatesTooltipShown:(RCTResponseSenderBlock)callback) RCT_EXTERN_METHOD(setStarterPageTemplatesTooltipShown:(BOOL)tooltipShown) -RCT_EXTERN_METHOD(requestStoryCreatorLoad:(NSArray *)mediaFiles blockId:(NSString *)blockId) +RCT_EXTERN_METHOD(requestMediaFilesEditorLoad:(NSArray *)mediaFiles blockId:(NSString *)blockId) RCT_EXTERN_METHOD(actionButtonPressed:(NSString *)buttonType) @end diff --git a/packages/react-native-bridge/ios/RNReactNativeGutenbergBridge.swift b/packages/react-native-bridge/ios/RNReactNativeGutenbergBridge.swift index f2c81ecc085abb..c7dbfa38e6632e 100644 --- a/packages/react-native-bridge/ios/RNReactNativeGutenbergBridge.swift +++ b/packages/react-native-bridge/ios/RNReactNativeGutenbergBridge.swift @@ -289,11 +289,11 @@ public class RNReactNativeGutenbergBridge: RCTEventEmitter { } @objc - func requestStoryCreatorLoad(_ mediaFilesArray: [AnyObject], blockId: String) { + func requestMediaFilesEditorLoad(_ mediaFilesArray: [AnyObject], blockId: String) { // TODO actually implement the delegate call on iOS let mediaFiles = mediaFilesArray.compactMap { $0 as? String } // DispatchQueue.main.async { - // self.delegate?.gutenbergDidRequestStoryCreatorLoad(mediaFiles: mediaFiles, blockId: blockId) + // self.delegate?.gutenbergDidRequestMediaFilesEditorLoad(mediaFiles: mediaFiles, blockId: blockId) // } } diff --git a/packages/react-native-editor/android/app/src/main/java/com/gutenberg/MainApplication.java b/packages/react-native-editor/android/app/src/main/java/com/gutenberg/MainApplication.java index 2193936128fba7..a32138a0dba2e8 100644 --- a/packages/react-native-editor/android/app/src/main/java/com/gutenberg/MainApplication.java +++ b/packages/react-native-editor/android/app/src/main/java/com/gutenberg/MainApplication.java @@ -85,7 +85,7 @@ public void mediaUploadSync(MediaSelectedCallback mediaSelectedCallback) { } @Override - public void storySaveSync(MediaSelectedCallback mediaSelectedCallback) { + public void mediaSaveSync(MediaSelectedCallback mediaSelectedCallback) { } @Override @@ -177,14 +177,14 @@ public void onAddMention(Consumer onSuccess) { } @Override - public void requestStoryCreatorLoad( - ReplaceStoryEditedBlockCallback replaceStoryEditedBlockCallback, + public void requestMediaFilesEditorLoad( + ReplaceMediaFilesEditedBlockCallback replaceMediaFilesEditedBlockCallback, ReadableArray mediaFiles, String blockId ) { // mReplaceStoryEditedBlockCallback = replaceStoryEditedBlockCallback; - // mOnStoryCreatorLoadRequestListener.onRequestStoryCreatorLoad(content, blockId); - Toast.makeText(MainApplication.this, "requestStoryCreatorLoad called", Toast.LENGTH_SHORT).show(); + // mOnMediaFilesEditorLoadRequestListener.onRequestMediaFilesEditorLoad(content, blockId); + Toast.makeText(MainApplication.this, "requestMediaFilesEditorLoad called", Toast.LENGTH_SHORT).show(); } @Override