@@ -92,30 +92,32 @@ export class Frigade extends Fetchable {
92
92
apiKey,
93
93
...config ,
94
94
} )
95
- this . init ( this . config )
96
- if ( isWeb ( ) && this . config . syncOnWindowUpdates !== false ) {
97
- document . addEventListener ( 'visibilitychange' , this . visibilityChangeHandler )
98
- // @ts -ignore
99
- if ( window . navigation ) {
95
+ this . init ( this . config ) . then ( ( ) => {
96
+ if ( isWeb ( ) && this . config . syncOnWindowUpdates !== false ) {
97
+ document . addEventListener ( 'visibilitychange' , this . visibilityChangeHandler )
100
98
// @ts -ignore
101
- window . navigation . addEventListener ( 'navigate' , async ( event ) => {
102
- try {
103
- if ( this . getGlobalState ( ) . currentUrl === event . destination . url ) {
104
- return
105
- }
106
- // if the new base url is the same but with a hashtag, don't refresh the state as the page has not changed.
107
- if (
108
- event . destination . url &&
109
- this . getGlobalState ( ) . currentUrl &&
110
- event . destination . url . split ( '#' ) [ 0 ] === this . getGlobalState ( ) . currentUrl . split ( '#' ) [ 0 ]
111
- ) {
112
- return
113
- }
114
- this . queueRefreshStateFromAPI ( )
115
- } catch ( e ) { }
116
- } )
99
+ if ( window . navigation ) {
100
+ // @ts -ignore
101
+ window . navigation . addEventListener ( 'navigate' , async ( event ) => {
102
+ try {
103
+ if ( this . getGlobalState ( ) . currentUrl === event . destination . url ) {
104
+ return
105
+ }
106
+ // if the new base url is the same but with a hashtag, don't refresh the state as the page has not changed.
107
+ if (
108
+ event . destination . url &&
109
+ this . getGlobalState ( ) . currentUrl &&
110
+ event . destination . url . split ( '#' ) [ 0 ] ===
111
+ this . getGlobalState ( ) . currentUrl . split ( '#' ) [ 0 ]
112
+ ) {
113
+ return
114
+ }
115
+ this . queueRefreshStateFromAPI ( )
116
+ } catch ( e ) { }
117
+ } )
118
+ }
117
119
}
118
- }
120
+ } )
119
121
}
120
122
121
123
/**
@@ -280,7 +282,12 @@ export class Frigade extends Fetchable {
280
282
* @ignore
281
283
*/
282
284
public isReady ( ) : boolean {
283
- return Boolean ( this . config . __instanceId && this . config . apiKey && this . initPromise )
285
+ return Boolean (
286
+ this . config . __instanceId &&
287
+ this . config . apiKey &&
288
+ this . initPromise &&
289
+ frigadeGlobalState [ getGlobalStateKey ( this . config ) ]
290
+ )
284
291
}
285
292
286
293
/**
0 commit comments