99} from '@strapi/design-system' ;
1010import { Data } from '@strapi/strapi' ;
1111import { Layouts , Page , useRBAC } from '@strapi/strapi/admin' ;
12- import { QueryClient , QueryClientProvider } from '@tanstack/react-query' ;
12+ import { QueryClient , QueryClientProvider , useQueryClient } from '@tanstack/react-query' ;
1313import { first , isEmpty } from 'lodash' ;
1414import { SyntheticEvent , useCallback , useEffect , useMemo , useState } from 'react' ;
1515import { useIntl } from 'react-intl' ;
@@ -32,6 +32,8 @@ import {
3232 useConfig ,
3333 useCopyNavigationI18n ,
3434 useI18nCopyNavigationItemsModal ,
35+ useInvalidateLocale ,
36+ useInvalidateNavigations ,
3537 useLocale ,
3638 useNavigations ,
3739 usePurgeNavigation ,
@@ -92,15 +94,19 @@ const Inner = () => {
9294
9395 const [ currentLocale , setCurrentLocale ] = useState < string > ( ) ;
9496 const [ isChangeLanguageVisible , setIsChangeLanguageVisible ] = useState ( false ) ;
95- const changeCurrentLocaleAction = useMemo ( ( ) => makeAction < string > ( {
96- perform : ( next ) => {
97- setCurrentLocale ( next ) ;
98- setIsChangeLanguageVisible ( false ) ;
99- setStructureChanged ( false ) ;
100- } ,
101- trigger : ( ) => setIsChangeLanguageVisible ( true ) ,
102- cancel : ( ) => setIsChangeLanguageVisible ( false ) ,
103- } ) , [ setCurrentLocale , setIsChangeLanguageVisible ] ) ;
97+ const changeCurrentLocaleAction = useMemo (
98+ ( ) =>
99+ makeAction < string > ( {
100+ perform : ( next ) => {
101+ setCurrentLocale ( next ) ;
102+ setIsChangeLanguageVisible ( false ) ;
103+ setStructureChanged ( false ) ;
104+ } ,
105+ trigger : ( ) => setIsChangeLanguageVisible ( true ) ,
106+ cancel : ( ) => setIsChangeLanguageVisible ( false ) ,
107+ } ) ,
108+ [ setCurrentLocale , setIsChangeLanguageVisible ]
109+ ) ;
104110
105111 const viewPermissions = useMemo (
106112 ( ) => ( {
@@ -215,6 +221,9 @@ const Inner = () => {
215221 const resetContentTypes = useResetContentTypes ( ) ;
216222 const resetNavigations = useResetNavigations ( ) ;
217223
224+ const invalidateLocaleQuery = useInvalidateLocale ( ) ;
225+ const invalidateNavigationsQuery = useInvalidateNavigations ( ) ;
226+
218227 const {
219228 i18nCopyItemsModal,
220229 i18nCopySourceLocale,
@@ -441,7 +450,6 @@ const Inner = () => {
441450 }
442451 } , [ navigationsQuery . data , currentNavigation ] ) ;
443452
444-
445453 useEffect ( ( ) => {
446454 if ( currentNavigation && currentLocale !== currentNavigation . locale ) {
447455 setRecentNavigation ( undefined ) ;
@@ -469,6 +477,11 @@ const Inner = () => {
469477 }
470478 } , [ navigationsQuery . data ] ) ;
471479
480+ useEffect ( ( ) => {
481+ invalidateLocaleQuery ( ) ;
482+ invalidateNavigationsQuery ( ) ;
483+ } , [ ] ) ;
484+
472485 if ( ! navigationsQuery . data || ! localeQuery . data || ! ! pending ) {
473486 return < Page . Loading /> ;
474487 }
0 commit comments