@@ -2,28 +2,20 @@ import {
22 applyUpdateMessageToBlocksState ,
33 getApi ,
44 getUserLanguage ,
5- type LanguageOption ,
65 log ,
76 parseWebsocketMessage ,
8- type UserProperties ,
97} from "@flows/shared" ;
10- import { blocks , blocksError , blocksState , pendingMessages } from "../store" ;
8+ import { blocks , blocksError , blocksState , config , pendingMessages } from "../store" ;
119import { type Disconnect , websocket } from "./websocket" ;
1210import { packageAndVersion } from "./constants" ;
1311
14- interface Props {
15- apiUrl : string ;
16- environment : string ;
17- organizationId : string ;
18- userId : string ;
19- userProperties ?: UserProperties ;
20- language ?: LanguageOption ;
21- }
22-
2312let disconnect : Disconnect | null = null ;
2413
25- export const connectToWebsocketAndFetchBlocks = ( props : Props ) : void => {
26- const { environment, organizationId, userId, apiUrl } = props ;
14+ export const connectToWebsocketAndFetchBlocks = ( ) : void => {
15+ const configuration = config . value ;
16+ if ( ! configuration ) return ;
17+
18+ const { environment, organizationId, userId, apiUrl, customFetch } = configuration ;
2719 const params = { environment, organizationId, userId } ;
2820 const wsUrl = ( ( ) => {
2921 const wsBase = apiUrl . replace ( "https://" , "wss://" ) . replace ( "http://" , "ws://" ) ;
@@ -32,11 +24,11 @@ export const connectToWebsocketAndFetchBlocks = (props: Props): void => {
3224
3325 const fetchBlocks = ( ) : void => {
3426 blocksError . value = false ;
35- void getApi ( apiUrl , packageAndVersion )
27+ void getApi ( { apiUrl, version : packageAndVersion , customFetch } )
3628 . getBlocks ( {
3729 ...params ,
38- language : getUserLanguage ( props . language ) ,
39- userProperties : props . userProperties ,
30+ language : getUserLanguage ( configuration . language ) ,
31+ userProperties : configuration . userProperties ,
4032 } )
4133 . then ( ( res ) => {
4234 const blocksWithUpdates = pendingMessages . value . reduce (
0 commit comments