File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,26 +47,26 @@ const load = ({
4747 beforeInit ( )
4848
4949 window . FrontChat ( 'init' , {
50- chatId : providerKey
50+ chatId : providerKey ,
51+ onInitCompleted : ( ) => {
52+ setState ( 'complete' )
53+ onReady ( )
54+ // 👇 Add state to Track when Front is fully initialized
55+ window . FrontChat . hasInitialized = true
56+ }
5157 //Read more: https://dev.frontapp.com/docs/chat-sdk-reference
5258 } )
5359 } )
54-
55- // Continue as long as frontchat hasn’t already been initialised.
56- if ( loaded ) {
57- waitForLoad (
58- ( ) => window . FrontChat ,
59- // Allow frontchat to complete loading before removing fake widget
60- ( ) =>
61- setTimeout ( ( ) => {
62- setState ( 'complete' )
63- onReady ( )
64- } , 2000 )
65- )
66- }
6760 return loaded
6861}
69- const open = ( ) => window . FrontChat ( 'show' )
62+
63+ const open = ( ) : void => {
64+ waitForLoad (
65+ ( ) => window . FrontChat ?. hasInitialized ,
66+ ( ) => window . FrontChat ( 'show' )
67+ )
68+ }
69+
7070export default {
7171 domain,
7272 load,
You can’t perform that action at this time.
0 commit comments