@@ -24,6 +24,7 @@ export default class GleapFrameManager {
24
24
frameUrl = "https://messenger-app.gleap.io" ;
25
25
gleapFrameContainer = null ;
26
26
gleapFrame = null ;
27
+ comReady = false ;
27
28
injectedFrame = false ;
28
29
widgetOpened = false ;
29
30
listeners = [ ] ;
@@ -57,14 +58,14 @@ export default class GleapFrameManager {
57
58
function appHeight ( ) {
58
59
try {
59
60
const doc = document . documentElement ;
60
- doc . style . setProperty ( ' --glvh' , ( window . innerHeight * .01 ) + 'px' ) ;
61
- } catch ( e ) { }
61
+ doc . style . setProperty ( " --glvh" , window . innerHeight * 0 .01 + "px" ) ;
62
+ } catch ( e ) { }
62
63
}
63
64
64
65
try {
65
- window . addEventListener ( ' resize' , appHeight ) ;
66
+ window . addEventListener ( " resize" , appHeight ) ;
66
67
appHeight ( ) ;
67
- } catch ( e ) { }
68
+ } catch ( e ) { }
68
69
}
69
70
}
70
71
@@ -73,7 +74,11 @@ export default class GleapFrameManager {
73
74
}
74
75
75
76
isSurvey ( ) {
76
- return this . appMode === "survey" || this . appMode === "survey_full" || this . appMode === "survey_web" ;
77
+ return (
78
+ this . appMode === "survey" ||
79
+ this . appMode === "survey_full" ||
80
+ this . appMode === "survey_web"
81
+ ) ;
77
82
}
78
83
79
84
setAppMode ( appMode ) {
@@ -84,7 +89,9 @@ export default class GleapFrameManager {
84
89
".gleap-frame-container-inner"
85
90
) ;
86
91
if (
87
- ( this . appMode === "widget" || this . appMode === "survey_full" || this . appMode === "survey_web" ) &&
92
+ ( this . appMode === "widget" ||
93
+ this . appMode === "survey_full" ||
94
+ this . appMode === "survey_web" ) &&
88
95
innerContainer
89
96
) {
90
97
innerContainer . style . maxHeight = `${ widgetMaxHeight } px` ;
@@ -173,8 +180,7 @@ export default class GleapFrameManager {
173
180
showImage = ( url ) => {
174
181
runFunctionWhenDomIsReady ( ( ) => {
175
182
var elem = document . createElement ( "div" ) ;
176
- elem . className =
177
- "gleap-image-view" ;
183
+ elem . className = "gleap-image-view" ;
178
184
elem . innerHTML = `<div class="gleap-image-view-close">
179
185
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm97.9-320l-17 17-47 47 47 47 17 17L320 353.9l-17-17-47-47-47 47-17 17L158.1 320l17-17 47-47-47-47-17-17L192 158.1l17 17 47 47 47-47 17-17L353.9 192z"/></svg>
180
186
</div><img class="gleap-image-view-image" src="${ url } " />` ;
@@ -226,9 +232,9 @@ export default class GleapFrameManager {
226
232
const flowConfig = GleapConfigManager . getInstance ( ) . getFlowConfig ( ) ;
227
233
if (
228
234
flowConfig . feedbackButtonPosition ===
229
- GleapFeedbackButtonManager . FEEDBACK_BUTTON_CLASSIC ||
235
+ GleapFeedbackButtonManager . FEEDBACK_BUTTON_CLASSIC ||
230
236
flowConfig . feedbackButtonPosition ===
231
- GleapFeedbackButtonManager . FEEDBACK_BUTTON_CLASSIC_BOTTOM
237
+ GleapFeedbackButtonManager . FEEDBACK_BUTTON_CLASSIC_BOTTOM
232
238
) {
233
239
styleToApply = classicStyle ;
234
240
}
@@ -399,14 +405,14 @@ export default class GleapFrameManager {
399
405
sendMessage ( data , queue = false ) {
400
406
try {
401
407
this . gleapFrame = document . querySelector ( ".gleap-frame" ) ;
402
- if ( this . gleapFrame && this . gleapFrame . contentWindow ) {
408
+ if ( this . comReady && this . gleapFrame && this . gleapFrame . contentWindow ) {
403
409
this . gleapFrame . contentWindow . postMessage ( JSON . stringify ( data ) , "*" ) ;
404
410
} else {
405
411
if ( queue ) {
406
412
this . queue . push ( data ) ;
407
413
}
408
414
}
409
- } catch ( e ) { }
415
+ } catch ( e ) { }
410
416
}
411
417
412
418
sendSessionUpdate ( ) {
@@ -459,6 +465,7 @@ export default class GleapFrameManager {
459
465
// Listen for messages.
460
466
this . addMessageListener ( ( data ) => {
461
467
if ( data . name === "ping" ) {
468
+ this . comReady = true ;
462
469
this . sendConfigUpdate ( ) ;
463
470
this . sendSessionUpdate ( ) ;
464
471
this . workThroughQueue ( ) ;
@@ -517,7 +524,9 @@ export default class GleapFrameManager {
517
524
".gleap-frame-container-inner"
518
525
) ;
519
526
if (
520
- ( this . appMode === "survey" || this . appMode === "survey_full" || this . appMode === "survey_web" ) &&
527
+ ( this . appMode === "survey" ||
528
+ this . appMode === "survey_full" ||
529
+ this . appMode === "survey_web" ) &&
521
530
innerContainer
522
531
) {
523
532
innerContainer . style . maxHeight = `${ this . frameHeight } px` ;
@@ -590,7 +599,10 @@ export default class GleapFrameManager {
590
599
591
600
// Add window message listener.
592
601
window . addEventListener ( "message" , ( event ) => {
593
- if ( ( event . origin !== this . frameUrl && event . origin !== GleapBannerManager . getInstance ( ) . bannerUrl ) ) {
602
+ if (
603
+ event . origin !== this . frameUrl &&
604
+ event . origin !== GleapBannerManager . getInstance ( ) . bannerUrl
605
+ ) {
594
606
return ;
595
607
}
596
608
@@ -601,7 +613,7 @@ export default class GleapFrameManager {
601
613
this . listeners [ i ] ( data ) ;
602
614
}
603
615
}
604
- } catch ( exp ) { }
616
+ } catch ( exp ) { }
605
617
} ) ;
606
618
}
607
619
0 commit comments