File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77
88## [ Unreleased]
99
10+ ### Added
11+ - Custom callback param to the localesChanged event.
12+
1013## [ 8.127.0] - 2021-03-10
1114
1215### Added
Original file line number Diff line number Diff line change @@ -964,9 +964,14 @@ export class RenderProvider extends Component<
964964 return assetsPromise
965965 }
966966
967- public onLocaleSelected = ( locale : string , domain ?: string ) => {
967+ public onLocaleSelected = (
968+ locale : string ,
969+ domain ?: string ,
970+ callback ?: ( ) => unknown
971+ ) => {
968972 if ( locale !== this . state . culture . locale ) {
969973 const sessionData = { public : { } }
974+
970975 if ( domain && domain === 'admin' ) {
971976 sessionData . public = {
972977 admin_cultureInfo : {
@@ -980,13 +985,20 @@ export class RenderProvider extends Component<
980985 } ,
981986 }
982987 }
983- this . patchSession ( sessionData )
984- . then ( ( ) => window . location . reload ( ) )
988+
989+ return this . patchSession ( sessionData )
990+ . then ( ( ) => {
991+ if ( callback ) return callback ( )
992+
993+ return window . location . reload ( )
994+ } )
985995 . catch ( ( e ) => {
986996 console . log ( 'Failed to fetch new locale file.' )
987997 console . error ( e )
988998 } )
989999 }
1000+
1001+ return undefined
9901002 }
9911003
9921004 public updateRuntime = async ( options ?: PageContextOptions ) => {
You can’t perform that action at this time.
0 commit comments