decord/source/actions/StreamActionCreators.tsx
2026-07-31 08:44:05 +00:00

481 lines
16 KiB
TypeScript

// Module ID: 4373
// Function ID: 4374
// Name: watchStream
// Dependencies: [5, 4207, 4374, 4375, 4212, 1218, 1372, 1862, 1931, 4209, 676, 4258, 709, 4257, 38, 4376, 4387, 4398, 530, 687, 5003, 503, 8860, 5005, 4203, 8926, 2]
// Exports: changeStreamRegion, closeStream, fetchStreamPreview, joinPrivateChannelAndWatchStream, notifyStreamStart, setLayout, setStreamPaused, startStream, stopOwnStream, stopStream, toggleSelfStreamHidden, updateStreamSettings, watchStreamAndTransitionToStream
// Module 4373 (watchStream)
import fetchFingerprint from "fetchFingerprint";
import set from "set";
import initialize from "initialize";
import reset from "reset";
import closure_7 from "reset";
import closure_8 from "fetchFingerprint";
import ensureGuildLoaded from "ensureGuildLoaded";
import createGuildRecordFromRust from "createGuildRecordFromRust";
import handleConnectionOpen from "handleConnectionOpen";
import updateVoiceState from "updateVoiceState";
import ME from "ME";
import { StreamTypes } from "StreamIssueReportReasons";
let closure_14;
let closure_15;
let map1;
const require = arg1;
function watchStream(stream, forceMultiple) {
if (null == remoteSessionId.getRemoteSessionId()) {
const channelId = stream.channelId;
if (null == stream.guildId) {
const encodeStreamKeyResult = require(4257) /* isStreamKey */.encodeStreamKey(stream);
forceMultiple = undefined;
if (forceMultiple != null) {
forceMultiple = forceMultiple.forceMultiple;
}
if (!forceMultiple) {
const allActiveStreamsForChannel = authStore.getAllActiveStreamsForChannel(channelId);
forceMultiple = allActiveStreamsForChannel.filter((ownerId) => ownerId.ownerId !== id.getId()).length >= MAX_VALUE;
}
const obj2 = require(4257) /* isStreamKey */;
const tmp18 = importDefault;
let obj = { type: "STREAM_WATCH", streamKey: null, allowMultiple: null };
obj[1] = encodeStreamKeyResult;
obj[2] = forceMultiple;
importDefault(709).dispatch(obj);
let forceFocus;
if (forceMultiple != null) {
forceFocus = forceMultiple.forceFocus;
}
let tmp21 = true !== forceFocus;
if (tmp21) {
if (!forceMultiple) {
let noFocus;
if (forceMultiple != null) {
noFocus = forceMultiple.noFocus;
}
forceMultiple = noFocus;
}
tmp21 = forceMultiple;
}
if (!tmp21) {
const participant = tmp18(4387).selectParticipant(stream.channelId, encodeStreamKeyResult);
const tmp18Result = tmp18(4387);
}
const obj3 = importDefault(709);
} else {
const channel = store.getChannel(channelId);
importDefault(38)(null != channel, "Cannot join a null voice channel");
const isInChannelResult = updateVoiceState.isInChannel(channelId);
let isChannelFullResult = !isInChannelResult;
if (!isInChannelResult) {
obj = require(4376) /* allowChannelAccess */;
isChannelFullResult = obj.isChannelFull(channel, tmp6, createGuildRecordFromRust);
}
tmp6 = updateVoiceState;
}
}
}
function _fetchStreamPreview() {
const self = this;
const tmp = callback((arg0, arg1, arg2) => {
let closure_0 = arg0;
let closure_1 = arg1;
let closure_2 = arg2;
let c7 = 0;
let c8 = 0;
let c6 = 0;
return (function*(arg0, arg1, arg2) {
if (c8 === 2) {
c8 = 3;
HermesBuiltin.throwTypeError();
} else if (tmp6 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
return { value: "HermesInternal", done: null };
}
} else {
try {
c8 = 2;
if (0 === c7) {
if (arg0 === 1) {
c8 = 3;
throw arg1;
} else if (arg0 === 2) {
c8 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
let set = tmp3;
let fetchFingerprint = tmp7;
let timestamp = dependencyMap;
let c0;
let lib;
dependencyMap = undefined;
if (c6.shouldFetchPreview(c0, lib, dependencyMap)) {
let obj5 = callback;
let result = callback(4257);
let HTTP = result.encodeStreamKey;
if (null != tmp55) {
let CALL = outer1_16.GUILD;
} else {
CALL = outer1_16.CALL;
}
const obj1 = { streamType: null, guildId: null, channelId: null, ownerId: null };
obj1[0] = CALL;
obj1[1] = tmp55;
obj1[2] = Date;
obj1[3] = timestamp;
const HTTPResult = HTTP(obj1);
c0 = HTTPResult;
let obj7 = lib(709);
const obj2 = { type: "STREAM_PREVIEW_FETCH_START", streamKey: null };
obj2[1] = HTTPResult;
obj7.dispatch(obj2);
c6 = 1;
HTTP = obj5(530).HTTP;
let obj3 = { url: null, query: null, oldFormErrors: true, rejectWithError: null };
obj3[0] = outer1_13.STREAM_PREVIEW(HTTPResult);
const obj4 = { version: null };
timestamp = Date.now();
obj4[0] = timestamp;
obj3[1] = obj4;
obj5 = obj5(530);
result = obj5.rejectWithMigratedError();
obj3[3] = result;
const value = HTTP.get(obj3);
c7 = 2;
c8 = 1;
}
}
} else {
if (1 === tmp7) {
c6 = 0;
fetchFingerprint = initialize;
if (429 === fetchFingerprint.status) {
dependencyMap = fetchFingerprint.body.retry_after * lib(687).Millis.SECOND;
}
obj3 = lib(709);
obj5 = { type: "STREAM_PREVIEW_FETCH_FAIL", streamKey: null, retryAfter: null };
obj5[1] = c0;
obj5[2] = dependencyMap;
obj3.dispatch(obj5);
} else if (arg0 === 1) {
c8 = 3;
throw arg1;
} else if (arg0 !== 2) {
lib = arg1;
obj = lib(709);
const obj6 = { type: "STREAM_PREVIEW_FETCH_SUCCESS", streamKey: null, previewURL: null };
obj6[1] = c0;
obj6[2] = lib.body.url;
obj.dispatch(obj6);
c6 = 0;
}
c6 = 0;
c8 = 3;
obj7 = { value: null, done: true };
obj7[0] = arg1;
return obj7;
}
c8 = 3;
} catch (tmp45) {
initialize = tmp45;
if (tmp4 === c6) {
c8 = tmp2;
throw tmp45;
} else {
c7 = tmp;
}
}
}
})();
});
const _fetchStreamPreview = tmp;
const apply = tmp.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
}
function _notifyStreamStart() {
const self = this;
const tmp = callback((arg0) => {
let closure_0 = arg0;
let c2 = 0;
let c1 = 0;
let c4 = 0;
return (function*(arg0) {
if (v0 === 2) {
v0 = 3;
HermesBuiltin.throwTypeError();
} else if (tmp5 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
return { value: "HermesInternal", done: null };
}
} else {
try {
v0 = 2;
if (0 === dependencyMap) {
if (arg0 === 1) {
v0 = 3;
throw arg1;
} else if (arg0 === 2) {
v0 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
let c4 = 1;
const obj1 = { url: null, oldFormErrors: true, trackedActionData: null, rejectWithError: true };
obj1[0] = outer1_13.STREAM_NOTIFY(callback);
const obj2 = { event: null };
obj2[0] = callback(503).NetworkActionNames.STREAM_NOTIFY;
obj1[2] = obj2;
dependencyMap = 2;
v0 = 1;
const obj3 = { value: null, done: false };
obj3[0] = v0(5003).post(obj1);
return obj3;
}
} else {
if (1 === tmp6) {
c4 = 0;
v0 = 3;
} else if (arg0 === 1) {
v0 = 3;
throw arg1;
} else if (arg0 !== 2) {
c4 = 0;
}
c4 = 0;
v0 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
}
} catch (tmp8) {
let fetchFingerprint = tmp8;
if (tmp3 === c4) {
v0 = tmp2;
throw tmp8;
} else {
dependencyMap = tmp;
}
}
}
})();
});
const _notifyStreamStart = tmp;
const apply = tmp.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
}
({ Endpoints: map1, AppContext: closure_14, PopoutWindowKeys: closure_15 } = ME);
let result = require("initialize").fileFinishedImporting("actions/StreamActionCreators.tsx");
export const startStream = function startStream(guildId, channelId) {
let obj = importDefault(709);
if (null != guildId) {
let CALL = StreamTypes.GUILD;
} else {
CALL = StreamTypes.CALL;
}
obj = { type: "STREAM_START", streamType: CALL, guildId, channelId, appContext: constants.APP };
const merged = Object.assign(arg2);
obj.dispatch(obj);
};
export const setStreamPaused = function setStreamPaused(currentUserActiveStream, paused) {
let obj = require(4257) /* isStreamKey */;
const encodeStreamKeyResult = obj.encodeStreamKey(currentUserActiveStream);
obj = { type: "STREAM_SET_PAUSED", streamKey: encodeStreamKeyResult, paused };
importDefault(709).dispatch(obj);
};
export { watchStream };
export const toggleSelfStreamHidden = function toggleSelfStreamHidden(channelId, selfStreamHidden) {
let obj = importDefault(709);
obj = { type: "STREAM_UPDATE_SELF_HIDDEN", channelId, selfStreamHidden };
obj.dispatch(obj);
};
export const watchStreamAndTransitionToStream = function watchStreamAndTransitionToStream(stream, forceMultiple) {
const channelId = stream.channelId;
if (null == stream.guildId) {
watchStream(stream, forceMultiple);
windowOpen = windowOpen.getWindowOpen(constants2.CHANNEL_CALL_POPOUT);
if (windowOpen) {
windowOpen = store2.getVoiceChannelId() === channelId;
}
if (!windowOpen) {
importDefault(4398)(stream);
}
} else {
const channel = store.getChannel(channelId);
importDefault(38)(null != channel, "Cannot join a null voice channel");
const isInChannelResult = updateVoiceState.isInChannel(channelId);
let isChannelFullResult = !isInChannelResult;
if (!isInChannelResult) {
isChannelFullResult = require(4376) /* allowChannelAccess */.isChannelFull(channel, tmp6, createGuildRecordFromRust);
const obj = require(4376) /* allowChannelAccess */;
}
tmp6 = updateVoiceState;
}
};
export const stopStream = function stopStream(streamKey) {
let flag = arg1;
if (arg1 === undefined) {
flag = true;
}
let flag2 = arg2;
if (arg2 === undefined) {
flag2 = true;
}
if (flag2) {
if (flag === undefined) {
flag = true;
}
let obj = importDefault(709);
obj = { type: "STREAM_CLOSE", streamKey: null, canShowFeedback: null };
obj[1] = streamKey;
obj[2] = flag;
obj.dispatch(obj);
}
obj = { type: "STREAM_STOP", streamKey, appContext: constants.APP };
importDefault(709).dispatch(obj);
};
export const closeStream = function closeStream(encodeStreamKeyResult1, arg1) {
let flag = arg1;
if (arg1 === undefined) {
flag = true;
}
let obj = importDefault(709);
obj = { type: "STREAM_CLOSE", streamKey: encodeStreamKeyResult1, canShowFeedback: flag };
obj.dispatch(obj);
};
export const fetchStreamPreview = function fetchStreamPreview(closure_0, closure_1, closure_2) {
const self = this;
const apply = _fetchStreamPreview.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
};
export const setLayout = function setLayout(layout) {
let obj = importDefault(709);
obj = { type: "STREAM_LAYOUT_UPDATE", layout };
obj.dispatch(obj);
};
export const notifyStreamStart = function notifyStreamStart() {
const self = this;
const apply = _notifyStreamStart.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
};
export const updateStreamSettings = function updateStreamSettings(noTrack) {
if (true !== noTrack.noTrack) {
let obj = require(8860) /* isPremiumResolution */;
const result = obj.trackStreamSettingsUpdate(noTrack.preset, noTrack.resolution, noTrack.frameRate, noTrack.soundshareEnabled);
}
obj = { type: "STREAM_UPDATE_SETTINGS" };
const merged = Object.assign(noTrack);
importDefault(709).dispatch(obj);
};
export const changeStreamRegion = function changeStreamRegion(encodeStreamKeyResult, preferredRegion) {
const HTTP = require(530) /* sendRequest */.HTTP;
obj = { url: closure_13.STREAM(encodeStreamKeyResult), body: obj, oldFormErrors: true, rejectWithError: true };
obj = { region: preferredRegion };
HTTP.patch(obj);
};
export const stopOwnStream = function stopOwnStream(arg0) {
let flag = arg0;
if (arg0 === undefined) {
flag = true;
}
const currentUserActiveStream = authStore.getCurrentUserActiveStream();
if (null != currentUserActiveStream) {
const encodeStreamKeyResult = require(4257) /* isStreamKey */.encodeStreamKey(currentUserActiveStream);
if (flag === undefined) {
flag = true;
}
if (flag === undefined) {
flag = true;
}
let obj = importDefault(709);
obj = { type: "STREAM_CLOSE", streamKey: null, canShowFeedback: null };
obj[1] = encodeStreamKeyResult;
obj[2] = flag;
obj.dispatch(obj);
const obj5 = require(4257) /* isStreamKey */;
obj = { type: "STREAM_STOP", streamKey: null, appContext: null };
obj[1] = encodeStreamKeyResult;
obj[2] = constants.APP;
importDefault(709).dispatch(obj);
const obj3 = importDefault(709);
}
};
export const joinPrivateChannelAndWatchStream = function joinPrivateChannelAndWatchStream(arg0, streamKey) {
const _require = arg0;
id = id.getId();
const importDefault = _require(4257).decodeStreamKey(streamKey);
const voiceChannelId = store2.getVoiceChannelId();
if (tmp4) {
importDefault(5005).disconnect();
const obj2 = importDefault(5005);
}
let obj = _require(4257);
tmp4 = null != voiceChannelId && voiceChannelId !== arg0;
importDefault(4203).addRecipient(arg0, id, undefined, () => {
const tmp = callback(outer1_2[25]);
const call = tmp.call;
const fn = () => {
const channelId = closure_1.channelId;
if (null == closure_1.guildId) {
outer1_18(tmp, undefined);
let windowOpen = outer1_5.getWindowOpen(outer1_15.CHANNEL_CALL_POPOUT);
if (windowOpen) {
windowOpen = outer1_11.getVoiceChannelId() === channelId;
}
if (!windowOpen) {
outer1_1(outer1_2[17])(tmp);
}
} else {
const channel = outer1_9.getChannel(channelId);
outer1_1(outer1_2[14])(null != channel, "Cannot join a null voice channel");
const isInChannelResult = outer1_12.isInChannel(channelId);
let isChannelFullResult = !isInChannelResult;
if (!isInChannelResult) {
isChannelFullResult = outer1_0(tmp5[15]).isChannelFull(channel, tmp7, outer1_10);
const obj = outer1_0(tmp5[15]);
}
tmp5 = outer1_2;
tmp7 = outer1_12;
}
};
if (typeof call === "unknown") {
tmp(false, false, null, fn);
} else {
call(tmp2, false, false, null, fn);
}
});
};