Files
discord-decomp/sources/actions/StreamActionCreators.tsx
T
2026-07-28 01:06:53 +03:00

665 lines
31 KiB
TypeScript

/* Metro module 8913; source: actions/StreamActionCreators.tsx; dependencies: [5, 4295, 8043, 8914, 4492, 1226, 1379, 1867, 1934, 4297, 661, 4286, 694, 4285, 44, 4800, 7712, 8915, 507, 672, 5046, 480, 8912, 4796, 4603, 8916, 2] */
import Module00005 from '../by-id/module-00005.js'; /* Metro dependency 5 */
import Module00044 from '../by-id/module-00044.js'; /* Metro dependency 44 */
import Dispatcher from '../Dispatcher.tsx'; /* Metro dependency 694 */
import AuthenticationStore from '../stores/AuthenticationStore.tsx'; /* Metro dependency 1226 */
import ChannelStore from '../stores/ChannelStore.tsx'; /* Metro dependency 1379 */
import GuildStore from '../stores/GuildStore.tsx'; /* Metro dependency 1867 */
import SelectedChannelStore from '../stores/SelectedChannelStore.tsx'; /* Metro dependency 1934 */
import GameConsoleStore from '../modules/game_console/GameConsoleStore.tsx'; /* Metro dependency 4295 */
import VoiceStateStore from '../stores/VoiceStateStore.tsx'; /* Metro dependency 4297 */
import ApplicationStreamingStore from '../stores/ApplicationStreamingStore.tsx'; /* Metro dependency 4492 */
import ChannelActionCreators from './ChannelActionCreators.tsx'; /* Metro dependency 4603 */
import PopoutWindowStoreNative from '../modules/popout-window/PopoutWindowStore.native.tsx'; /* Metro dependency 8043 */
import ApplicationStreamPreviewStore from '../stores/ApplicationStreamPreviewStore.tsx'; /* Metro dependency 8914 */
import * as FileImportTrackerModule from '../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ConstantsModule from '../Constants.tsx'; /* Metro dependency 661 */
import * as StreamKeyUtilsModule from '../modules/go_live/utils/StreamKeyUtils.tsx'; /* Metro dependency 4285 */
import * as ConstantsModule2 from '../modules/go_live/Constants.tsx'; /* Metro dependency 4286 */
function _fun69539(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#69539, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9098:6, offset: 0x01c76232, size: 566 bytes, params: 8, frame: 24
const env0_0 = require;
const watchStream2 = watchStream;
const watchStreamAndTransitionToStream2 = watchStreamAndTransitionToStream;
const stopStream2 = stopStream;
const closeStream2 = closeStream;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const Number = global.Number;
const env0_17 = Number.MAX_VALUE;
(FileImportTrackerModule).fileFinishedImporting('actions/StreamActionCreators.tsx');
exports.startStream = function(a0, a1, a2) {
var r7;
var r6;
var defaultImport = importDefault(dependencyMap[12]);
var dispatch = defaultImport.dispatch;
var object = {type: 'STREAM_START'};
if (a0 != null) {
r6 = StreamTypes.GUILD;
r7 = StreamTypes;
} else {
r6 = StreamTypes.CALL;
}
object.streamType = r6;
object.guildId = a0;
object.channelId = a1;
object.appContext = AppContext.APP;
copyDataProperties(object, a2, r7);
Reflect.apply(dispatch, defaultImport, [object]);
};
exports.setStreamPaused = setStreamPaused;
exports.watchStream = watchStream2;
exports.toggleSelfStreamHidden = toggleSelfStreamHidden;
exports.watchStreamAndTransitionToStream = watchStreamAndTransitionToStream2;
exports.stopStream = stopStream2;
exports.closeStream = closeStream2;
exports.fetchStreamPreview = function() {
return _fetchStreamPreview.apply(this, arguments);
};
exports.setLayout = setLayout_69556;
exports.notifyStreamStart = function() {
return _notifyStreamStart.apply(this, arguments);
};
exports.updateStreamSettings = updateStreamSettings;
exports.changeStreamRegion = function(a0, a1) {
var HTTP = require(dependencyMap[18]).HTTP;
var object = {};
object.url = Endpoints.STREAM(a0);
object.body = {region: a1};
object.oldFormErrors = true;
object.rejectWithError = true;
HTTP.patch(object);
};
exports.stopOwnStream = stopOwnStream;
exports.joinPrivateChannelAndWatchStream = joinPrivateChannelAndWatchStream;
function isVoiceChannelFull(a0, a1) { // fn#69540, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9098:299, offset: 0x01c76468, size: 124 bytes, params: 3, frame: 17
var r0;
var moduleValue;
const channel = ChannelStore.getChannel(a1);
(Module00044)(channel != null, 'Cannot join a null voice channel');
const isInChannel2 = VoiceStateStore.isInChannel(a1);
if (isInChannel2) {
r0 = !isInChannel2;
} else {
moduleValue = require(4800) /* metro dependency 4800: ChannelUtils */;
r0 = moduleValue.isChannelFull(channel, VoiceStateStore, GuildStore);
}
return r0;
}
function watchStream(a0, a1) { // fn#69541, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9098:463, offset: 0x01c764e4, size: 304 bytes, params: 3, frame: 20
var forceMultiple;
var r5;
var guildId;
var channelId;
var value3;
var value4;
var allActiveStreamsForChannel;
var defaultImport;
var value;
if (GameConsoleStore.getRemoteSessionId() == null) {
guildId = a0.guildId;
channelId = a0.channelId;
if (guildId == null) {
value3 = undefined;
value4 = (require(4285) /* metro dependency 4285: StreamKeyUtils */).encodeStreamKey(a0);
forceMultiple = a1 == null ? value3 : a1.forceMultiple;
if (forceMultiple) {
r5 = forceMultiple;
} else {
allActiveStreamsForChannel = ApplicationStreamingStore.getAllActiveStreamsForChannel(channelId);
r5 = allActiveStreamsForChannel.filter(function({ownerId}) {
return ownerId !== AuthenticationStore.getId();
}).length >= MAX_VALUE;
}
defaultImport = importDefault(694) /* metro dependency 694: Dispatcher */;
defaultImport.dispatch({type: 'STREAM_WATCH', streamKey: value4, allowMultiple: r5});
if (!((a1 == null ? value3 : a1.forceFocus) !== true && (!r5 ? a1 != null && a1.noFocus : r5))) {
value = importDefault(7712) /* metro dependency 7712: ChannelRTCActionCreators */;
value.selectParticipant(a0.channelId, value4);
}
} else if (!isVoiceChannelFull(undefined, channelId)) {
value3 = undefined;
value4 = (require(4285) /* metro dependency 4285: StreamKeyUtils */).encodeStreamKey(a0);
forceMultiple = a1 == null ? value3 : a1.forceMultiple;
if (forceMultiple) {
r5 = forceMultiple;
} else {
allActiveStreamsForChannel = ApplicationStreamingStore.getAllActiveStreamsForChannel(channelId);
r5 = allActiveStreamsForChannel.filter(_fun69542).length >= MAX_VALUE;
}
defaultImport = importDefault(694) /* metro dependency 694: Dispatcher */;
defaultImport.dispatch({type: 'STREAM_WATCH', streamKey: value4, allowMultiple: r5});
if (!((a1 == null ? value3 : a1.forceFocus) !== true && (!r5 ? a1 != null && a1.noFocus : r5))) {
value = importDefault(7712) /* metro dependency 7712: ChannelRTCActionCreators */;
value.selectParticipant(a0.channelId, value4);
}
}
}
function _fun69542({ownerId}) { // fn#69542, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9098:706, offset: 0x01c76614, size: 32 bytes, params: 2, frame: 10
const authenticationStoreBinding = AuthenticationStore;
const getId = authenticationStoreBinding.getId;
return ownerId !== Reflect.apply(getId, authenticationStoreBinding, []);
}
}
function watchStreamAndTransitionToStream(a0, a1) { // fn#69543, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9098:921, offset: 0x01c76634, size: 133 bytes, params: 3, frame: 16
var popoutWindowStoreNativeBinding;
const guildId = a0.guildId;
const channelId = a0.channelId;
if (guildId == null) {
watchStream(a0, a1);
popoutWindowStoreNativeBinding = PopoutWindowStoreNative;
if (!(popoutWindowStoreNativeBinding.getWindowOpen(PopoutWindowKeys.CHANNEL_CALL_POPOUT) && SelectedChannelStore.getVoiceChannelId() === channelId)) {
(importDefault(8915) /* metro dependency 8915: transitionToStreamNative */)(a0);
}
} else if (!isVoiceChannelFull(undefined, channelId)) {
watchStream(a0, a1);
popoutWindowStoreNativeBinding = PopoutWindowStoreNative;
if (!(popoutWindowStoreNativeBinding.getWindowOpen(PopoutWindowKeys.CHANNEL_CALL_POPOUT) && SelectedChannelStore.getVoiceChannelId() === channelId)) {
(importDefault(8915) /* metro dependency 8915: transitionToStreamNative */)(a0);
}
}
}
function stopStream(a0) { // fn#69544, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9098:1145, offset: 0x01c766b9, size: 104 bytes, params: 2, frame: 16
const value = a1;
const value2 = a2;
if (!(value2 !== undefined) || value2) {
closeStream(a0, !(value !== undefined) || value);
}
const defaultImport = Dispatcher;
const dispatch = defaultImport.dispatch;
const APP = AppContext.APP;
Reflect.apply(dispatch, defaultImport, [{type: 'STREAM_STOP', streamKey: a0, appContext: APP}]);
}
function closeStream(a0) { // fn#69545, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9098:1267, offset: 0x01c76721, size: 69 bytes, params: 2, frame: 14
let value = a1;
const r4 = !(value !== undefined) || value;
value = importDefault(694) /* metro dependency 694: Dispatcher */;
value.dispatch({type: 'STREAM_CLOSE', streamKey: a0, canShowFeedback: r4});
}
function _fetchStreamPreview() { // fn#69546, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9098:1367, offset: 0x01c76766, size: 50 bytes, params: 1, frame: 14
return Module00005(_fun69548).apply(this, arguments);
function* _fun69548(a0, a1, a2) { // fn#69548, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9098:1428, offset: 0x01c767a3, size: 492 bytes, params: 4, frame: 24
var r12;
var r5;
var value3;
var binding;
var shouldFetchPreview;
var value4;
var encodeStreamKey;
var object;
var CALL;
var GUILD;
var value5;
var value6;
var dispatch;
var binding2;
var property;
var value7;
var HTTP;
var get;
var STREAM_PREVIEW;
var value8;
var object2;
var Date;
var now;
var value9;
var value10;
var value11;
var value12;
var binding3;
var value13;
var body;
var url;
var error;
var status;
var retry_after;
var Millis;
var SECOND;
var value14;
var value15;
let value = undefined;
if (true) {
reduciblePort52: while (true) {
exceptionLanding49: while (true) {
value = undefined;
value3 = environment.__proto__.__proto__;
binding = env2_6;
shouldFetchPreview = binding.shouldFetchPreview;
if (Reflect.apply(shouldFetchPreview, binding, [a0, a1, a2])) {
binding = env2_0;
value4 = binding(env2_2[13]);
encodeStreamKey = value4.encodeStreamKey;
if (a0 != null) {
GUILD = env2_16.GUILD;
r12 = GUILD;
} else {
CALL = env2_16.CALL;
r12 = CALL;
}
value5 = Reflect.apply(encodeStreamKey, value4, [{streamType: r12, guildId: a0, channelId: a1,
ownerId: a2}]);
binding = env2_1;
value6 = binding(env2_2[12]);
dispatch = value6.dispatch;
Reflect.apply(dispatch, value6, [{type: 'STREAM_PREVIEW_FETCH_START', streamKey: value5}]);
try {
binding = env2_0;
} catch (error) {
break exceptionLanding49;
}
try {
binding2 = env2_2;
} catch (error) {
break exceptionLanding49;
}
try {
property = binding2[18];
} catch (error) {
break exceptionLanding49;
}
try {
value7 = binding(property);
} catch (error) {
break exceptionLanding49;
}
try {
HTTP = value7.HTTP;
} catch (error) {
break exceptionLanding49;
}
try {
get = HTTP.get;
} catch (error) {
break exceptionLanding49;
}
try {
object = {};
} catch (error) {
break exceptionLanding49;
}
try {
binding = env2_13;
} catch (error) {
break exceptionLanding49;
}
try {
STREAM_PREVIEW = binding.STREAM_PREVIEW;
} catch (error) {
break exceptionLanding49;
}
try {
value8 = Reflect.apply(STREAM_PREVIEW, binding, [value5]);
} catch (error) {
break exceptionLanding49;
}
try {
object.url = value8;
} catch (error) {
break exceptionLanding49;
}
try {
object2 = {};
} catch (error) {
break exceptionLanding49;
}
try {
Date = global.Date;
} catch (error) {
break exceptionLanding49;
}
try {
now = Date.now;
} catch (error) {
break exceptionLanding49;
}
try {
value9 = Reflect.apply(now, Date, []);
} catch (error) {
break exceptionLanding49;
}
try {
object2.version = value9;
} catch (error) {
break exceptionLanding49;
}
try {
object.query = object2;
} catch (error) {
break exceptionLanding49;
}
try {
object.oldFormErrors = true;
} catch (error) {
break exceptionLanding49;
}
try {
object.rejectWithError = false;
} catch (error) {
break exceptionLanding49;
}
try {
value10 = Reflect.apply(get, HTTP, [object]);
} catch (error) {
break exceptionLanding49;
}
yield value10;
try {
value11 = undefined;
value12 = false;
} catch (error) {
break exceptionLanding49;
}
if (value12) {
return value11;
}
try {
binding = env2_1;
} catch (error) {
break exceptionLanding49;
}
try {
binding3 = env2_2;
} catch (error) {
break exceptionLanding49;
}
try {
property = binding3[12];
} catch (error) {
break exceptionLanding49;
}
try {
value13 = binding(property);
} catch (error) {
break exceptionLanding49;
}
try {
dispatch = value13.dispatch;
} catch (error) {
break exceptionLanding49;
}
try {
object = {};
} catch (error) {
break exceptionLanding49;
}
try {
object.type = 'STREAM_PREVIEW_FETCH_SUCCESS';
} catch (error) {
break exceptionLanding49;
}
try {
object.streamKey = value5;
} catch (error) {
break exceptionLanding49;
}
try {
body = value11.body;
} catch (error) {
break exceptionLanding49;
}
try {
url = body.url;
} catch (error) {
break exceptionLanding49;
}
try {
object.previewURL = url;
} catch (error) {
break exceptionLanding49;
}
try {
Reflect.apply(dispatch, value13, [object]);
} catch (error) {
break exceptionLanding49;
}
break reduciblePort52;
}
break reduciblePort52;
}
status = error.status;
reducibleJoin51: while (true) {
if (status !== 429) {
r5 = value;
break reducibleJoin51;
}
body = error.body;
retry_after = body.retry_after;
binding = env2_1;
Millis = binding(env2_2[19]).Millis;
SECOND = Millis.SECOND;
value14 = retry_after * SECOND;
r5 = value14;
break reducibleJoin51;
}
binding = env2_1;
value15 = binding(env2_2[12]);
dispatch = value15.dispatch;
Reflect.apply(dispatch, value15, [{type: 'STREAM_PREVIEW_FETCH_FAIL', streamKey: value5, retryAfter: r5}]);
break reduciblePort52;
}
}
return value;
}
}
function _notifyStreamStart() { // fn#69549, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9098:2043, offset: 0x01c7698f, size: 50 bytes, params: 1, frame: 14
return Module00005(_fun69551).apply(this, arguments);
function* _fun69551(a0) { // fn#69551, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9098:2102, offset: 0x01c769cc, size: 146 bytes, params: 2, frame: 18
var binding;
var binding2;
var property;
var value3;
var post;
var object;
var STREAM_NOTIFY;
var value4;
var object2;
var NetworkActionNames;
var value5;
var error;
if (true) {
value = environment.__proto__.__proto__;
try {
binding = env2_1;
} catch (error) {
return undefined;
}
try {
binding2 = env2_2;
} catch (error) {
return undefined;
}
try {
property = binding2[20];
} catch (error) {
return undefined;
}
try {
value3 = binding(property);
} catch (error) {
return undefined;
}
try {
post = value3.post;
} catch (error) {
return undefined;
}
try {
object = {};
} catch (error) {
return undefined;
}
try {
binding = env2_13;
} catch (error) {
return undefined;
}
try {
STREAM_NOTIFY = binding.STREAM_NOTIFY;
} catch (error) {
return undefined;
}
try {
value4 = Reflect.apply(STREAM_NOTIFY, binding, [a0]);
} catch (error) {
return undefined;
}
try {
object.url = value4;
} catch (error) {
return undefined;
}
try {
object.oldFormErrors = true;
} catch (error) {
return undefined;
}
try {
object2 = {};
} catch (error) {
return undefined;
}
try {
binding = env2_0;
} catch (error) {
return undefined;
}
try {
property = binding2[21];
} catch (error) {
return undefined;
}
try {
value = binding(property);
} catch (error) {
return undefined;
}
try {
NetworkActionNames = value.NetworkActionNames;
} catch (error) {
return undefined;
}
try {
STREAM_NOTIFY = NetworkActionNames.STREAM_NOTIFY;
} catch (error) {
return undefined;
}
try {
object2.event = STREAM_NOTIFY;
} catch (error) {
return undefined;
}
try {
object.trackedActionData = object2;
} catch (error) {
return undefined;
}
try {
object.rejectWithError = true;
} catch (error) {
return undefined;
}
try {
value = Reflect.apply(post, value3, [object]);
} catch (error) {
return undefined;
}
yield value;
try {
value = undefined;
value5 = false;
} catch (error) {
return undefined;
}
if (value5) {
return value;
}
}
}
}
function setStreamPaused(a0, a1) { // fn#69553, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9098:2553, offset: 0x01c76ad5, size: 90 bytes, params: 3, frame: 14
const value2 = (StreamKeyUtilsModule).encodeStreamKey(a0);
Dispatcher.dispatch({type: 'STREAM_SET_PAUSED', streamKey: value2, paused: a1});
}
function toggleSelfStreamHidden(a0, a1) { // fn#69554, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9098:2736, offset: 0x01c76b2f, size: 62 bytes, params: 3, frame: 13
(Dispatcher).dispatch({type: 'STREAM_UPDATE_SELF_HIDDEN',
channelId: a0, selfStreamHidden: a1});
}
function setLayout_69556(a0) { // fn#69556, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9098:3090, offset: 0x01c76b6d, size: 57 bytes, params: 2, frame: 13
(Dispatcher).dispatch({type: 'STREAM_LAYOUT_UPDATE', layout: a0});
}
function updateStreamSettings(a0) { // fn#69558, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9098:3292, offset: 0x01c76ba6, size: 136 bytes, params: 2, frame: 18
var r8;
var value;
var trackStreamSettingsUpdate;
var preset;
var resolution;
var frameRate;
if (a0.noTrack !== true) {
value = require(8912) /* metro dependency 8912: StreamQualityUtils */;
trackStreamSettingsUpdate = value.trackStreamSettingsUpdate;
preset = a0.preset;
resolution = a0.resolution;
frameRate = a0.frameRate;
Reflect.apply(trackStreamSettingsUpdate, value, [preset, resolution, frameRate, a0.soundshareEnabled]);
r8 = frameRate;
}
value = importDefault(694) /* metro dependency 694: Dispatcher */;
const dispatch = value.dispatch;
const object = {type: 'STREAM_UPDATE_SETTINGS'};
copyDataProperties(object, a0, r8);
Reflect.apply(dispatch, value, [object]);
}
function stopOwnStream() { // fn#69560, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9098:3650, offset: 0x01c76c8a, size: 77 bytes, params: 1, frame: 16
var stopStreamBinding;
let value = a0;
const r3 = !(value !== undefined) || value;
const currentUserActiveStream = ApplicationStreamingStore.getCurrentUserActiveStream();
if (currentUserActiveStream != null) {
stopStreamBinding = stopStream;
value = require(4285) /* metro dependency 4285: StreamKeyUtils */;
stopStreamBinding(value.encodeStreamKey(currentUserActiveStream), r3);
}
}
function joinPrivateChannelAndWatchStream(a0, a1) { // fn#69561, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9098:3803, offset: 0x01c76cd7, size: 176 bytes, params: 3, frame: 19
const env0_0 = a0;
const id = AuthenticationStore.getId();
const env0_1 = (StreamKeyUtilsModule).decodeStreamKey(a1);
const voiceChannelId = SelectedChannelStore.getVoiceChannelId();
if (voiceChannelId != null && voiceChannelId !== a0) {
(importDefault(4796) /* metro dependency 4796: SelectedChannelActionCreators */).disconnect();
}
(ChannelActionCreators).addRecipient(a0, id, undefined, _fun69562);
function _fun69562() { // fn#69562, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9098:3992, offset: 0x01c76d87, size: 61 bytes, params: 1, frame: 19
var environment;
let value = environment.__proto__;
value = importDefault(8916) /* metro dependency 8916: CallActionCreators */;
value.call(env0_0, false, false, null, _fun69563);
function _fun69563() { // fn#69563, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9098:4025, offset: 0x01c76dc4, size: 23 bytes, params: 1, frame: 11
watchStreamAndTransitionToStream(env1_1);
}
}
}
}
global.__d(_fun69539, 8913, [5, 4295, 8043, 8914, 4492, 1226, 1379, 1867, 1934, 4297, 661, 4286, 694, 4285, 44,
4800, 7712, 8915, 507, 672, 5046, 480, 8912, 4796, 4603, 8916,
2]) /* metro module 8913, dependencies: [5, 4295, 8043, 8914, 4492, 1226, 1379, 1867, 1934, 4297, 661, 4286, 694, 4285, 44, 4800, 7712, 8915, 507, 672, 5046, 480, 8912, 4796, 4603, 8916, 2] */;