@@ -30,27 +30,37 @@ const MemoizedChat = React.memo(function ChatComponent({
3030 httpTokens . refreshToken = refresh ;
3131 } ;
3232
33- const firebaseConfig = useMemo ( ( ) => {
34- const allowedDomains =
35- import . meta. env . VITE_APP_ALLOWED_DOMAINS ?. split ( ',' ) || [ ] ;
36- const currentDomain = window . location . hostname ;
33+ const allowedDomains = import . meta. env . VITE_APP_ALLOWED_DOMAINS ?. split ( ',' ) || [ ] ;
34+ const currentDomain = window . location . hostname ;
35+ const pushEnabledByDomain = allowedDomains . includes ( currentDomain ) ;
3736
38- if ( ! allowedDomains . includes ( currentDomain ) ) {
37+ const firebaseConfig = useMemo ( ( ) => {
38+ if ( ! pushEnabledByDomain ) {
3939 return undefined ;
4040 }
4141
42- console . log ( "currentDomain" , currentDomain , allowedDomains . includes ( currentDomain ) ) ;
43-
44- return ( {
42+ const fireConfig = {
4543 apiKey : import . meta. env . VITE_FIREBASE_API_KEY ,
4644 authDomain : import . meta. env . VITE_FIREBASE_AUTH_DOMAIN ,
4745 projectId : import . meta. env . VITE_FIREBASE_PROJECT_ID ,
4846 storageBucket : import . meta. env . VITE_FIREBASE_STORAGE_BUCKET ,
4947 messagingSenderId : import . meta. env . VITE_FIREBASE_MESSAGING_SENDER_ID ,
5048 appId : import . meta. env . VITE_FIREBASE_APP_ID ,
5149 measurementId : import . meta. env . VITE_FIREBASE_MEASUREMENT_ID ,
52- } )
53- } , [ ] ) ;
50+ }
51+
52+ return fireConfig ;
53+ } , [ pushEnabledByDomain ] ) ;
54+
55+ const hasFirebaseConfig = Boolean (
56+ firebaseConfig ?. apiKey &&
57+ firebaseConfig ?. authDomain &&
58+ firebaseConfig ?. projectId &&
59+ firebaseConfig ?. messagingSenderId &&
60+ firebaseConfig ?. appId
61+ ) ;
62+
63+ const pushEnabled = pushEnabledByDomain && hasFirebaseConfig ;
5464
5565 return (
5666 // @ts -ignore
@@ -100,10 +110,22 @@ const MemoizedChat = React.memo(function ChatComponent({
100110 setRoomJidInPath : true ,
101111 enableRoomsRetry : { enabled : false , helperText : '' } ,
102112 pushNotifications : {
103- enabled : true ,
113+ enabled : pushEnabled ,
104114 softAsk : false ,
105115 firebaseConfig,
106116 } ,
117+ inAppNotifications : {
118+ enabled : true ,
119+ showInContext : true ,
120+ position : {
121+ horizontal : 'right' ,
122+ vertical : 'top' ,
123+ offset : {
124+ left : 20 ,
125+ bottom : 20 ,
126+ } ,
127+ } ,
128+ } ,
107129 } }
108130 />
109131 ) ;
0 commit comments