blob: 1ad5d9d145df3a579e4e885a6f3ea8e0169d8542 [file] [log] [blame]
Adrià Vilanova Martínez9c418ab2024-12-05 15:34:40 +01001import FetchProxy from '../../../xhrInterceptor/fetchProxy/FetchProxy';
2import InterceptorHandlerAdapter from '../../../xhrInterceptor/interceptors/InterceptorHandler.adapter';
3import interceptors from '../../../xhrInterceptor/interceptors/interceptors';
4import {KILL_SWITCH_LOCALSTORAGE_KEY, KILL_SWITCH_LOCALSTORAGE_VALUE} from '../../../xhrInterceptor/killSwitchHandler.js';
5import MessageIdTracker from '../../../xhrInterceptor/MessageIdTracker';
6import ResponseModifierAdapter from '../../../xhrInterceptor/ResponseModifier.adapter';
7import createMessageRemoveParentRef from '../../../xhrInterceptor/responseModifiers/createMessageRemoveParentRef';
8import flattenThread from '../../../xhrInterceptor/responseModifiers/flattenThread';
9import loadMoreThread from '../../../xhrInterceptor/responseModifiers/loadMoreThread';
10import { Modifier } from '../../../xhrInterceptor/responseModifiers/types';
11import XHRProxy from '../../../xhrInterceptor/XHRProxy';
12
13export const responseModifiers: Modifier[] = [
14 loadMoreThread,
15 flattenThread,
16 createMessageRemoveParentRef,
17];
18
19if (window.localStorage.getItem(KILL_SWITCH_LOCALSTORAGE_KEY) !==
20 KILL_SWITCH_LOCALSTORAGE_VALUE) {
21 const responseModifier = new ResponseModifierAdapter(responseModifiers);
22 const interceptorHandler = new InterceptorHandlerAdapter(interceptors.interceptors);
23 const messageIdTracker = new MessageIdTracker();
24
25 new XHRProxy(responseModifier, messageIdTracker);
26
27 const fetchProxy = new FetchProxy(responseModifier, interceptorHandler, messageIdTracker);
28 fetchProxy.enableInterception();
29}