Skip to content

Commit

Permalink
Merge pull request #9532 from google/enhancement/9348-fix-create-prop…
Browse files Browse the repository at this point in the history
…erty-regression
  • Loading branch information
nfmohit authored Oct 17, 2024
2 parents ace575e + d098d5b commit 28897c6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ export default function AccountCreateLegacy() {
[ createAccountURL, viewContext ]
);

const { resetAccountSummaries } = useDispatch( MODULES_ANALYTICS_4 );
const { resetAccountSummaries, resetAccountSettings } =
useDispatch( MODULES_ANALYTICS_4 );
const refetchAccountsHandler = useCallback( () => {
resetAccountSummaries();
}, [ resetAccountSummaries ] );
resetAccountSettings();
}, [ resetAccountSettings, resetAccountSummaries ] );

if ( ! hasResolvedAccounts ) {
return <ProgressBar />;
Expand Down
18 changes: 18 additions & 0 deletions assets/js/modules/analytics-4/datastore/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ const fetchCreateAccountStore = createFetchStore( {
const START_SELECTING_ACCOUNT = 'START_SELECTING_ACCOUNT';
const FINISH_SELECTING_ACCOUNT = 'FINISH_SELECTING_ACCOUNT';
const RESET_ACCOUNT_SUMMARIES = 'RESET_ACCOUNT_SUMMARIES';
const RESET_ACCOUNT_SETTINGS = 'RESET_ACCOUNT_SETTINGS';
const TRANSFORM_AND_SORT_ACCOUNT_SUMMARIES =
'TRANSFORM_AND_SORT_ACCOUNT_SUMMARIES';

Expand Down Expand Up @@ -141,6 +142,20 @@ const baseActions = {
).invalidateResolutionForStoreSelector( 'getAccountSummaries' );
},

/**
* Resets the account settings.
*
* @since n.e.x.t
*
* @return {Object} Redux-style action.
*/
resetAccountSettings() {
return {
payload: {},
type: RESET_ACCOUNT_SETTINGS,
};
},

/**
* Creates a new Analytics (GA4) account.
*
Expand Down Expand Up @@ -290,6 +305,9 @@ const baseReducer = createReducer( ( state, { type } ) => {

case RESET_ACCOUNT_SUMMARIES:
state.accountSummaries = undefined;
break;

case RESET_ACCOUNT_SETTINGS:
state.settings.accountID = undefined;
state.settings.propertyID = undefined;
state.settings.measurementID = undefined;
Expand Down

0 comments on commit 28897c6

Please sign in to comment.