Skip to content

Commit

Permalink
Resolve modules to ensure canViewSharedModules selectors have data.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmymadon committed Oct 12, 2024
1 parent 997ae88 commit 08a90fe
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions assets/js/googlesitekit/notifications/register-defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ export function registerDefaults( notificationsAPI ) {
CORE_MODULES
).isModuleConnected( 'analytics-4' );

if ( viewOnly ) {
// This ensures resolution for the canViewSharedModule() selectors.
await resolveSelect( CORE_MODULES ).getModules();
}

const canViewSharedAnalytics = ! viewOnly
? true
: select( CORE_USER ).canViewSharedModule( 'analytics-4' );
Expand Down Expand Up @@ -327,6 +332,9 @@ export function registerDefaults( notificationsAPI ) {
// If we are in the view only mode, we need to ensure the user can view the module
// and it is not in the recovering state. Return early if either of these is wrong.
if ( viewOnly ) {
// This ensures resolution for the canViewSharedModule() selectors.
await resolveSelect( CORE_MODULES ).getModules();

const canView =
select( CORE_USER ).canViewSharedModule( moduleSlug );
if ( ! canView ) {
Expand Down

0 comments on commit 08a90fe

Please sign in to comment.