Skip to content

Commit a051ea4

Browse files
committed
refactor: Rename AJAX and api-fetch configuration utilities
1 parent 470c268 commit a051ea4

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

src/utils/ajax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { warn, debug } from './logger';
1010
*
1111
* @return {void}
1212
*/
13-
export function initializeAjax() {
13+
export function configureAjax() {
1414
window.wp = window.wp || {};
1515
window.wp.ajax = window.wp.ajax || {};
1616
window.wp.ajax.settings = window.wp.ajax.settings || {};

src/utils/api-fetch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { getGBKit } from './bridge';
1818
*
1919
* @return {void}
2020
*/
21-
export function initializeApiFetch() {
21+
export function configureApiFetch() {
2222
const { siteApiRoot = '' } = getGBKit();
2323

2424
apiFetch.use( apiFetch.createRootURLMiddleware( siteApiRoot ) );

src/utils/api-fetch.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import apiFetch from '@wordpress/api-fetch';
1919
/**
2020
* Internal dependencies
2121
*/
22-
import { initializeApiFetch } from './api-fetch';
22+
import { configureApiFetch } from './api-fetch';
2323
import * as bridge from './bridge';
2424

2525
vi.mock( './bridge' );
@@ -34,7 +34,7 @@ describe( 'api-fetch credentials handling', () => {
3434
} );
3535

3636
// Initialize middleware once - it will persist across all tests
37-
initializeApiFetch();
37+
configureApiFetch();
3838
} );
3939

4040
beforeEach( () => {

src/utils/remote-editor.jsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
import { awaitGBKitGlobal } from './bridge';
55
import { loadEditorAssets } from './editor-loader';
6-
import { initializeAjax } from './ajax';
6+
import { configureAjax } from './ajax';
77
import { error, warn } from './logger';
88
import { isDevMode } from './dev-mode';
99
import './editor-styles.js';
@@ -32,7 +32,7 @@ export function initializeRemoteEditor() {
3232
.then( importL10n )
3333
.then( configureLocale ) // Configure locale before loading modules with strings
3434
.then( loadApiFetch )
35-
.then( initializeApiFetch ) // Configure API fetch before loading remaining modules
35+
.then( configureNetworkingUtils ) // Configure AJAX and api-fetch before loading remaining modules
3636
.then( loadRemainingAssets )
3737
.then( initializeEditor )
3838
.catch( handleError );
@@ -61,18 +61,16 @@ function loadRemainingAssets() {
6161
} );
6262
}
6363

64-
function initializeApiFetch( assetsResult ) {
65-
return import( './api-fetch' ).then(
66-
( { initializeApiFetch: _initializeApiFetch } ) => {
67-
_initializeApiFetch();
68-
return assetsResult;
69-
}
70-
);
64+
function configureNetworkingUtils( assetsResult ) {
65+
configureAjax();
66+
67+
return import( './api-fetch' ).then( ( { configureApiFetch } ) => {
68+
configureApiFetch();
69+
return assetsResult;
70+
} );
7171
}
7272

7373
function initializeEditor( assetsResult ) {
74-
initializeAjax();
75-
7674
const { allowedBlockTypes } = assetsResult;
7775
return import( './editor' ).then(
7876
( { initializeEditor: _initializeEditor } ) => {

0 commit comments

Comments
 (0)