32 lines
1.4 KiB
TypeScript
32 lines
1.4 KiB
TypeScript
// Metro module 16661 (f16662).
|
|
import { NativeModules } from "react-native";
|
|
import LocaleStore from "../../user_settings/LocaleStore";
|
|
import AuthenticationStore from "../../../stores/AuthenticationStore";
|
|
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
|
|
import { getAPIBaseURL } from "../../../_bundle/sendRequest";
|
|
import AutomaticLifecycleManager from "../../../lib/AutomaticLifecycleManager";
|
|
import { isAndroid } from "../../../utils/PlatformUtils";
|
|
const updateSocialRpcNetworkConfig = function updateSocialRpcNetworkConfig() {
|
|
const headers = {
|
|
"X-Super-Properties": AnalyticsUtils.getSuperPropertiesBase64(),
|
|
"X-Fingerprint": AuthenticationStore.getFingerprint(),
|
|
"X-Installation-ID": AuthenticationStore.getInstallationForTracking(),
|
|
"X-Discord-Locale": LocaleStore.locale
|
|
};
|
|
const NativeCacheModule = NativeModules.NativeCacheModule;
|
|
if (NativeCacheModule != null) {
|
|
NativeCacheModule.setItem("socialRpcNetworkRequest", JSON.stringify({
|
|
apiBaseUrl: getAPIBaseURL(),
|
|
headers
|
|
}));
|
|
}
|
|
};
|
|
class SocialRpcNetworkConfigManager extends AutomaticLifecycleManager {
|
|
handleUpdate = isAndroid() ? updateSocialRpcNetworkConfig : () => {};
|
|
actions = {
|
|
POST_CONNECTION_OPEN: this.handleUpdate
|
|
};
|
|
}
|
|
const socialRpcNetworkConfigManager = new SocialRpcNetworkConfigManager();
|
|
export default socialRpcNetworkConfigManager;
|