128 lines
5.3 KiB
TypeScript
128 lines
5.3 KiB
TypeScript
// Metro module 10745 (f10746).
|
|
import { useMemo } from "react";
|
|
import { NativeModules } from "react-native";
|
|
import ApplicationStreamingStore from "../../../stores/ApplicationStreamingStore";
|
|
import { ApplicationStreamStates } from "../../../Constants";
|
|
import { getSystemVersionMajor } from "../../../utils/native/DeviceUtils";
|
|
import ForegroundServiceManager_android from "../../foreground_service/mobile/ForegroundServiceManager.android";
|
|
import { getVoiceEngine } from "../../../_bundle/Module4238";
|
|
import { showScreenshareDisabledAlert } from "../../voice_calls/native/CallsUtils";
|
|
import { stopStream } from "../../../actions/StreamActionCreators";
|
|
import { encodeStreamKey } from "../../go_live/utils/StreamKeyUtils";
|
|
import AudioActionCreators from "../../../actions/AudioActionCreators";
|
|
import useHasVideoPermission, { getVideoPermission } from "../useHasVideoPermission";
|
|
import { isMetaQuest } from "../../device/MetaQuestUtils.android";
|
|
import Module10757 from "../../../_bundle/Module10757";
|
|
import Module10758 from "../../../_bundle/Module10758";
|
|
import MobileGoLiveUpsellExperiment from "../../go_live/native/MobileGoLiveUpsellExperiment";
|
|
import { useStateFromStores } from "../../../_bundle/Module589";
|
|
import useAnalyticsLocations from "../../app_analytics/useAnalyticsLocations";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
function $mk85467($env) {
|
|
return () => {
|
|
const r1 = $env.$parent;
|
|
return (0, r1[0])(r1[2][12]).showMobileGoLiveActionSheet($env[1]);
|
|
};
|
|
}
|
|
function $mk85468($env) {
|
|
return () => {
|
|
const r1 = $env.$parent;
|
|
const r2 = r1[0];
|
|
const r7 = r1[2];
|
|
r2(r7[11]).reportAVError({
|
|
type: r2(r7[11]).AVError.SCREENSHARE_OS_NOT_SUPPORTED,
|
|
channelId: $env[0].id
|
|
});
|
|
r2(r7[7]).showMinOSScreenshareRequirementAlert();
|
|
};
|
|
}
|
|
let startStream, c7222_6, BroadcastUploadManager;
|
|
let $mk107474 = function() {
|
|
return (a0) => {
|
|
if (a0) {
|
|
getVoiceEngine().startBroadcast();
|
|
} else {
|
|
showScreenshareDisabledAlert();
|
|
}
|
|
};
|
|
};
|
|
let env7222 = {};
|
|
export function stopScreenshare() {
|
|
getVoiceEngine().stopBroadcast();
|
|
const currentUserActiveStream = ApplicationStreamingStore.getCurrentUserActiveStream();
|
|
if (currentUserActiveStream != null) {
|
|
stopStream(encodeStreamKey(currentUserActiveStream));
|
|
}
|
|
AudioActionCreators.setGoLiveSource(null);
|
|
}
|
|
startStream = function startStream() {
|
|
if (getVoiceEngine().platform === "android") {
|
|
ForegroundServiceManager_android.isForegroundServiceRunning($mk107474());
|
|
} else {
|
|
BroadcastUploadManager.showPicker();
|
|
}
|
|
};
|
|
c7222_6 = getSystemVersionMajor();
|
|
BroadcastUploadManager = NativeModules.BroadcastUploadManager;
|
|
export default function useScreenshareUtils(a0) {
|
|
let analyticsLocations;
|
|
const hasVideoPermission = useHasVideoPermission(a0);
|
|
let c18246_1 = hasVideoPermission;
|
|
const isFeatureEnabled = c7222_6 >= 12;
|
|
const showMobileGoLiveUpsell = MobileGoLiveUpsellExperiment.useConfig({
|
|
location: "useScreenshareUtils"
|
|
}).showMobileGoLiveUpsell;
|
|
const stateFromStores = useStateFromStores([ApplicationStreamingStore], () => ApplicationStreamingStore.getCurrentUserActiveStream());
|
|
analyticsLocations = useAnalyticsLocations().analyticsLocations;
|
|
return useMemo(() => {
|
|
const isActive = stateFromStores != null && stateFromStores.state === ApplicationStreamStates.ACTIVE;
|
|
const isFeatureEnabled2 = c18246_1 && isFeatureEnabled;
|
|
const text = !showMobileGoLiveUpsell && isActive ? intl.string(t.CpkXwZ) : intl.string(t.fjBNo1);
|
|
let env26809;
|
|
const r43 = env7222;
|
|
const r46 = env26809 = {
|
|
$parent: r43
|
|
};
|
|
env26809[0] = a0;
|
|
const r48 = showMobileGoLiveUpsell === void 0 ? false : showMobileGoLiveUpsell;
|
|
env26809[1] = analyticsLocations;
|
|
return {
|
|
isFeatureEnabled: isFeatureEnabled2,
|
|
isActive,
|
|
text,
|
|
onPress: isFeatureEnabled ? c18246_1 ? r48 ? $mk85467(r46) : isActive ? stopScreenshare : startStream : showScreenshareDisabledAlert : $mk85468(r46),
|
|
imgSource: isMetaQuest() ? isActive ? Module10757 : Module10758 : importDefault(showMobileGoLiveUpsell ? dependencyMap[17] : isActive ? dependencyMap[18] : dependencyMap[17])
|
|
};
|
|
}, [stateFromStores, a0, hasVideoPermission, isFeatureEnabled, showMobileGoLiveUpsell, analyticsLocations]);
|
|
};
|
|
export function handleCloseScreenshare() {
|
|
const currentUserActiveStream = ApplicationStreamingStore.getCurrentUserActiveStream();
|
|
if (currentUserActiveStream != null) {
|
|
stopStream(encodeStreamKey(currentUserActiveStream));
|
|
}
|
|
AudioActionCreators.setGoLiveSource(null);
|
|
}
|
|
export { startStream };
|
|
export function getOSRequirement() {
|
|
return c7222_6 >= 12;
|
|
}
|
|
export function getStreamPressHandler(a0) {
|
|
let env18245;
|
|
const r3 = env18245 = {
|
|
$parent: env7222
|
|
};
|
|
env18245[0] = a0.channel;
|
|
const { hasPermission, isActive, osRequirement, showMobileGoLiveUpsell: showMobileGoLiveUpsell2 = false } = a0;
|
|
env18245[1] = a0.analyticsLocations;
|
|
return osRequirement ? hasPermission ? showMobileGoLiveUpsell2 ? $mk85467(r3) : isActive ? stopScreenshare : startStream : showScreenshareDisabledAlert : $mk85468(r3);
|
|
}
|
|
export function tryStartScreenShare(a0) {
|
|
if (c7222_6 >= 12 && getVideoPermission(a0)) {
|
|
if (getVoiceEngine().platform === "android") {
|
|
ForegroundServiceManager_android.isForegroundServiceRunning($mk107474());
|
|
} else {
|
|
BroadcastUploadManager.showPicker();
|
|
}
|
|
}
|
|
}
|