315 lines
9.7 KiB
TypeScript
315 lines
9.7 KiB
TypeScript
// Metro module 4369 (f4370).
|
|
import GameConsoleStore from "../modules/game_console/GameConsoleStore";
|
|
import PopoutWindowStore_native from "../modules/popout-window/PopoutWindowStore.native";
|
|
import ApplicationStreamPreviewStore from "../stores/ApplicationStreamPreviewStore";
|
|
import ApplicationStreamingStore from "../stores/ApplicationStreamingStore";
|
|
import AuthenticationStore from "../stores/AuthenticationStore";
|
|
import ChannelStore from "../stores/ChannelStore";
|
|
import GuildStore from "../stores/GuildStore";
|
|
import SelectedChannelStore from "../stores/SelectedChannelStore";
|
|
import VoiceStateStore from "../stores/VoiceStateStore";
|
|
import { AppContext, Endpoints, PopoutWindowKeys } from "../Constants";
|
|
import { StreamTypes } from "../modules/go_live/Constants";
|
|
import Dispatcher from "../Dispatcher";
|
|
import { encodeStreamKey, decodeStreamKey } from "../modules/go_live/utils/StreamKeyUtils";
|
|
import Module38 from "../_bundle/Module38";
|
|
import { isChannelFull } from "../utils/ChannelUtils";
|
|
import ChannelRTCActionCreators from "./ChannelRTCActionCreators";
|
|
import transitionToStream_native from "../modules/go_live/utils/transitionToStream.native";
|
|
import { HTTP, rejectWithMigratedError } from "../_bundle/sendRequest";
|
|
import Durations from "../utils/Durations";
|
|
import TrackedHTTPUtils from "../utils/TrackedHTTPUtils";
|
|
import { NetworkActionNames } from "../_bundle/Module503";
|
|
import { trackStreamSettingsUpdate } from "../utils/StreamQualityUtils";
|
|
import SelectedChannelActionCreators from "./SelectedChannelActionCreators";
|
|
import ChannelActionCreators from "./ChannelActionCreators";
|
|
import CallActionCreators from "./CallActionCreators";
|
|
let MAX_VALUE;
|
|
const watchStream = function watchStream(a0, a1) {
|
|
L19: {
|
|
if (GameConsoleStore.getRemoteSessionId() == null) {
|
|
const { guildId: guildId2, channelId: channelId2 } = a0;
|
|
if (guildId2 != null) {
|
|
const channel = ChannelStore.getChannel(channelId2);
|
|
Module38(channel != null, "Cannot join a null voice channel");
|
|
const isInChannel = VoiceStateStore.isInChannel(channelId2);
|
|
if (isInChannel ? !isInChannel : isChannelFull(channel, VoiceStateStore, GuildStore)) {
|
|
break L19;
|
|
}
|
|
}
|
|
const streamKey = encodeStreamKey(a0);
|
|
let allowMultiple = a1?.forceMultiple || ApplicationStreamingStore.getAllActiveStreamsForChannel(channelId2).filter((item) => item.ownerId !== AuthenticationStore.getId()).length >= MAX_VALUE;
|
|
Dispatcher.dispatch({
|
|
type: "STREAM_WATCH",
|
|
streamKey,
|
|
allowMultiple
|
|
});
|
|
let r55 = a1?.forceFocus !== true;
|
|
if (r55) {
|
|
if (!allowMultiple) {
|
|
allowMultiple = a1?.noFocus;
|
|
}
|
|
r55 = allowMultiple;
|
|
}
|
|
if (!r55) {
|
|
ChannelRTCActionCreators.selectParticipant(a0.channelId, streamKey);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
MAX_VALUE = Number.MAX_VALUE;
|
|
export function startStream(a0, a1, a2) {
|
|
Dispatcher.dispatch({
|
|
type: "STREAM_START",
|
|
streamType: a0 != null ? StreamTypes.GUILD : StreamTypes.CALL,
|
|
guildId: a0,
|
|
channelId: a1,
|
|
appContext: AppContext.APP,
|
|
...a2
|
|
});
|
|
}
|
|
export function setStreamPaused(a0, a1) {
|
|
Dispatcher.dispatch({
|
|
type: "STREAM_SET_PAUSED",
|
|
streamKey: encodeStreamKey(a0),
|
|
paused: a1
|
|
});
|
|
}
|
|
export { watchStream };
|
|
export function toggleSelfStreamHidden(a0, a1) {
|
|
Dispatcher.dispatch({
|
|
type: "STREAM_UPDATE_SELF_HIDDEN",
|
|
channelId: a0,
|
|
selfStreamHidden: a1
|
|
});
|
|
}
|
|
export function watchStreamAndTransitionToStream(a0, a1) {
|
|
L8: {
|
|
const { guildId: guildId2, channelId: channelId2 } = a0;
|
|
if (guildId2 != null) {
|
|
const channel = ChannelStore.getChannel(channelId2);
|
|
Module38(channel != null, "Cannot join a null voice channel");
|
|
const isInChannel = VoiceStateStore.isInChannel(channelId2);
|
|
if (isInChannel ? !isInChannel : isChannelFull(channel, VoiceStateStore, GuildStore)) {
|
|
break L8;
|
|
}
|
|
}
|
|
watchStream(a0, a1);
|
|
let r33 = PopoutWindowStore_native.getWindowOpen(PopoutWindowKeys.CHANNEL_CALL_POPOUT);
|
|
const voiceChannelId = SelectedChannelStore.getVoiceChannelId();
|
|
if (r33) {
|
|
r33 = voiceChannelId === channelId2;
|
|
}
|
|
if (!r33) {
|
|
transitionToStream_native(a0);
|
|
}
|
|
}
|
|
}
|
|
export function stopStream(a0, canShowFeedback = true, r2 = true) {
|
|
if (r2) {
|
|
if (canShowFeedback === void 0) {
|
|
canShowFeedback = true;
|
|
}
|
|
Dispatcher.dispatch({
|
|
type: "STREAM_CLOSE",
|
|
streamKey: a0,
|
|
canShowFeedback
|
|
});
|
|
}
|
|
Dispatcher.dispatch({
|
|
type: "STREAM_STOP",
|
|
streamKey: a0,
|
|
appContext: AppContext.APP
|
|
});
|
|
}
|
|
export function closeStream(a0, canShowFeedback = true) {
|
|
Dispatcher.dispatch({
|
|
type: "STREAM_CLOSE",
|
|
streamKey: a0,
|
|
canShowFeedback
|
|
});
|
|
}
|
|
export async function fetchStreamPreview(guildId, channelId, ownerId) {
|
|
let c25060_5;
|
|
let c25060_6 = 0;
|
|
let c29319_0, c29319_1, c29319_2, c29319_3;
|
|
L16: {
|
|
try {
|
|
c29319_0 = void 0;
|
|
c29319_1 = void 0;
|
|
c29319_2 = void 0;
|
|
if (ApplicationStreamPreviewStore.shouldFetchPreview(guildId, channelId, ownerId)) {
|
|
const streamKey = encodeStreamKey({
|
|
streamType: guildId != null ? StreamTypes.GUILD : StreamTypes.CALL,
|
|
guildId,
|
|
channelId,
|
|
ownerId
|
|
});
|
|
c29319_0 = streamKey;
|
|
Dispatcher.dispatch({
|
|
type: "STREAM_PREVIEW_FETCH_START",
|
|
streamKey
|
|
});
|
|
c25060_6 = 1;
|
|
c29319_1 = await HTTP.get({
|
|
url: Endpoints.STREAM_PREVIEW(streamKey),
|
|
query: {
|
|
version: Date.now()
|
|
},
|
|
oldFormErrors: true,
|
|
rejectWithError: rejectWithMigratedError()
|
|
});
|
|
Dispatcher.dispatch({
|
|
type: "STREAM_PREVIEW_FETCH_SUCCESS",
|
|
streamKey: c29319_0,
|
|
previewURL: c29319_1.body.url
|
|
});
|
|
c25060_6 = 0;
|
|
break L16;
|
|
}
|
|
} catch ($e) {
|
|
const r33 = $e;
|
|
let r8 = r33;
|
|
c25060_5 = r33;
|
|
if (c25060_6 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r109 = c25060_5;
|
|
c25060_6 = 0;
|
|
c29319_3 = r109;
|
|
if (c29319_3.status === 429) {
|
|
c29319_2 = c29319_3.body.retry_after * Durations.Millis.SECOND;
|
|
}
|
|
Dispatcher.dispatch({
|
|
type: "STREAM_PREVIEW_FETCH_FAIL",
|
|
streamKey: c29319_0,
|
|
retryAfter: c29319_2
|
|
});
|
|
break L16;
|
|
} catch (r106) {
|
|
r8 = r106;
|
|
c25060_5 = r106;
|
|
if (c25060_6 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
return void 0;
|
|
}
|
|
}
|
|
export function setLayout(a0) {
|
|
Dispatcher.dispatch({
|
|
type: "STREAM_LAYOUT_UPDATE",
|
|
layout: a0
|
|
});
|
|
}
|
|
export async function notifyStreamStart(c25061_0) {
|
|
let c25061_4 = 0;
|
|
L10: {
|
|
try {
|
|
c25061_4 = 1;
|
|
await TrackedHTTPUtils.post({
|
|
url: Endpoints.STREAM_NOTIFY(c25061_0),
|
|
oldFormErrors: true,
|
|
trackedActionData: {
|
|
event: NetworkActionNames.STREAM_NOTIFY
|
|
},
|
|
rejectWithError: true
|
|
});
|
|
c25061_4 = 0;
|
|
} catch ($e) {
|
|
let r8 = $e;
|
|
if (c25061_4 !== 0) {
|
|
while (true) {
|
|
try {
|
|
c25061_4 = 0;
|
|
break L10;
|
|
} catch ($e) {
|
|
r8 = $e;
|
|
if (c25061_4 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
}
|
|
}
|
|
export function updateStreamSettings(a0) {
|
|
if (a0.noTrack !== true) {
|
|
trackStreamSettingsUpdate(a0.preset, a0.resolution, a0.frameRate, a0.soundshareEnabled);
|
|
}
|
|
Dispatcher.dispatch({
|
|
type: "STREAM_UPDATE_SETTINGS",
|
|
...a0
|
|
});
|
|
}
|
|
export function changeStreamRegion(a0, a1) {
|
|
HTTP.patch({
|
|
url: Endpoints.STREAM(a0),
|
|
body: {
|
|
region: a1
|
|
},
|
|
oldFormErrors: true,
|
|
rejectWithError: true
|
|
});
|
|
}
|
|
export function stopOwnStream(canShowFeedback = true) {
|
|
const currentUserActiveStream = ApplicationStreamingStore.getCurrentUserActiveStream();
|
|
if (currentUserActiveStream != null) {
|
|
const streamKey = encodeStreamKey(currentUserActiveStream);
|
|
if (canShowFeedback === void 0) {
|
|
canShowFeedback = true;
|
|
}
|
|
if (canShowFeedback === void 0) {
|
|
canShowFeedback = true;
|
|
}
|
|
Dispatcher.dispatch({
|
|
type: "STREAM_CLOSE",
|
|
streamKey,
|
|
canShowFeedback
|
|
});
|
|
Dispatcher.dispatch({
|
|
type: "STREAM_STOP",
|
|
streamKey,
|
|
appContext: AppContext.APP
|
|
});
|
|
}
|
|
}
|
|
export function joinPrivateChannelAndWatchStream(a0, a1) {
|
|
const id = AuthenticationStore.getId();
|
|
let c14144_1 = decodeStreamKey(a1);
|
|
const voiceChannelId = SelectedChannelStore.getVoiceChannelId();
|
|
if (voiceChannelId != null && voiceChannelId !== a0) {
|
|
SelectedChannelActionCreators.disconnect();
|
|
}
|
|
ChannelActionCreators.addRecipient(a0, id, void 0, () => {
|
|
CallActionCreators.call(a0, false, false, null, () => {
|
|
L8: {
|
|
const { guildId: guildId2, channelId: channelId2 } = c14144_1;
|
|
if (guildId2 != null) {
|
|
const channel = ChannelStore.getChannel(channelId2);
|
|
Module38(channel != null, "Cannot join a null voice channel");
|
|
const isInChannel = VoiceStateStore.isInChannel(channelId2);
|
|
if (isInChannel ? !isInChannel : isChannelFull(channel, VoiceStateStore, GuildStore)) {
|
|
break L8;
|
|
}
|
|
}
|
|
watchStream(c14144_1, void 0);
|
|
let r33 = PopoutWindowStore_native.getWindowOpen(PopoutWindowKeys.CHANNEL_CALL_POPOUT);
|
|
const voiceChannelId = SelectedChannelStore.getVoiceChannelId();
|
|
if (r33) {
|
|
r33 = voiceChannelId === channelId2;
|
|
}
|
|
if (!r33) {
|
|
transitionToStream_native(c14144_1);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|