File tree 2 files changed +18
-3
lines changed 2 files changed +18
-3
lines changed 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.
7
7
8
8
## [ Unreleased]
9
9
10
+ ### Added
11
+ - Custom callback param to the localesChanged event.
12
+
10
13
## [ 8.127.0] - 2021-03-10
11
14
12
15
### Added
Original file line number Diff line number Diff line change @@ -964,9 +964,14 @@ export class RenderProvider extends Component<
964
964
return assetsPromise
965
965
}
966
966
967
- public onLocaleSelected = ( locale : string , domain ?: string ) => {
967
+ public onLocaleSelected = (
968
+ locale : string ,
969
+ domain ?: string ,
970
+ callback ?: ( ) => unknown
971
+ ) => {
968
972
if ( locale !== this . state . culture . locale ) {
969
973
const sessionData = { public : { } }
974
+
970
975
if ( domain && domain === 'admin' ) {
971
976
sessionData . public = {
972
977
admin_cultureInfo : {
@@ -980,13 +985,20 @@ export class RenderProvider extends Component<
980
985
} ,
981
986
}
982
987
}
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
+ } )
985
995
. catch ( ( e ) => {
986
996
console . log ( 'Failed to fetch new locale file.' )
987
997
console . error ( e )
988
998
} )
989
999
}
1000
+
1001
+ return undefined
990
1002
}
991
1003
992
1004
public updateRuntime = async ( options ?: PageContextOptions ) => {
You can’t perform that action at this time.
0 commit comments