Skip to content

Commit

Permalink
New Settings UI: Move request chaining fom control to action
Browse files Browse the repository at this point in the history
  • Loading branch information
hmouhtar committed Dec 17, 2024
1 parent fa2571f commit f31b78f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions modules/ppcp-settings/resources/js/data/common/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @file
*/

import { select } from '@wordpress/data';
import { dispatch, select } from '@wordpress/data';

import ACTION_TYPES from './action-types';
import { STORE_NAME } from './constants';
Expand Down Expand Up @@ -192,11 +192,17 @@ export const refreshMerchantData = function* () {

/**
* Side effect.
* Purges all features status data via a REST request.
* Purges all feature status data via a REST request.
* Refreshes the merchant data via a REST request.
*
* @return {Action} The action.
*/
export const refreshFeatureStatuses = function* () {
return yield { type: ACTION_TYPES.DO_REFRESH_FEATURES };
const result = yield { type: ACTION_TYPES.DO_REFRESH_FEATURES };

if ( result && result.success ) {
return yield dispatch( STORE_NAME ).refreshMerchantData();
}

return result;
};

0 comments on commit f31b78f

Please sign in to comment.