Files
discord-decomp/sources/modules/activities/native/EmbeddedActivityView.tsx
T
2026-07-28 01:06:53 +03:00

260 lines
16 KiB
TypeScript

/* Metro module 10704; source: modules/activities/native/EmbeddedActivityView.tsx; dependencies: [57, 31, 27, 1378, 4237, 4238, 33, 4501, 10703, 1478, 694, 10705, 10706, 10701, 566, 10708, 8092, 10709, 10716, 2] */
import Module00057 from '../../../by-id/module-00057.js'; /* Metro dependency 57 */
import EmbeddedActivitiesStore from '../EmbeddedActivitiesStore.tsx'; /* Metro dependency 1378 */
import UseCurrentEmbeddedApplication from '../utils/useCurrentEmbeddedApplication.tsx'; /* Metro dependency 10701 */
import UseDispatchOpenActivity from '../useDispatchOpenActivity.tsx'; /* Metro dependency 10708 */
import * as FileImportTrackerModule from '../../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ReactNativeModule from '../../../by-id/module-00027-ReactNative.js'; /* Metro dependency 27 */
import * as ReactModule from '../../../by-id/module-00031-React.js'; /* Metro dependency 31 */
import * as JsxRuntimeModule from '../../../by-id/module-00033-JsxRuntime.js'; /* Metro dependency 33 */
import * as FluxModule from '../../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */
import * as ConstantsModule from '../Constants.tsx'; /* Metro dependency 4237 */
import * as ApplicationConstantsModule from '../../applications/ApplicationConstants.tsx'; /* Metro dependency 4238 */
import * as CreateStylesModule from '../../../design/components/Styles/native/createStyles.tsx'; /* Metro dependency 4501 */
import * as GetDefaultOrientationLockStateModule from './getDefaultOrientationLockState.tsx'; /* Metro dependency 10703 */
function _fun82249(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#82249, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10890:6, offset: 0x01ef097a, size: 396 bytes, params: 8, frame: 23
const env0_0 = require;
const useBaseActivityView2 = useBaseActivityView;
const ActivityViewLoadingIndicator2 = ActivityViewLoadingIndicator;
const BaseActivityView2 = BaseActivityView;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
let value = ReactModule;
const env0_14 = (CreateStylesModule).createStyles({loadingContainer: {'flex': 1,
'justifyContent': 'center'}});
value = value.memo(EmbeddedActivityViewInner);
(FileImportTrackerModule).fileFinishedImporting('modules/activities/native/EmbeddedActivityView.tsx');
exports.default = value;
exports.useBaseActivityView = useBaseActivityView2;
exports.ActivityViewLoadingIndicator = ActivityViewLoadingIndicator2;
exports.BaseActivityView = BaseActivityView2;
exports.EmbeddedActivityView = value;
function useBaseActivityView({orientationLockState, showLoadingIndicator, setShowLoadingStateForLockingOrientation, application, setOrientationLockState}) { // fn#82250, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10890:392, offset: 0x01ef0b06, size: 460 bytes, params: 2, frame: 27
const application2 = application;
const setOrientationLockState2 = setOrientationLockState;
let value = undefined;
const [property, property2] = application2(setOrientationLockState2.useState(false), 2);
const defaultOrientationLockState = (GetDefaultOrientationLockStateModule).getDefaultOrientationLockState(application);
const id = application == null ? value : application.id;
const [property3, env0_8] = application2(setOrientationLockState2.useState(false), 2);
value = (importDefault(1478) /* metro dependency 1478: useWindowDimensionsNative */)();
value = value.width > value.height;
setOrientationLockState2.useLayoutEffect(_fun82251, [value]);
setOrientationLockState2.useLayoutEffect(_fun82252, [id]);
setOrientationLockState2.useLayoutEffect(_fun82253, [defaultOrientationLockState, application, orientationLockState,
value, property3, setShowLoadingStateForLockingOrientation, setOrientationLockState]);
setOrientationLockState2.useLayoutEffect(_fun82254, [orientationLockState, value,
setShowLoadingStateForLockingOrientation]);
setOrientationLockState2.useLayoutEffect(_fun82255, [showLoadingIndicator, property]);
return {isResetting: property, setIsResetting: property2, isLandscape: value};
function _fun82251() { // fn#82251, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10890:760, offset: 0x01ef0cd2, size: 82 bytes, params: 1, frame: 14
let value = environment.__proto__;
const r4 = ConstantsModule.ActivityScreenOrientation ? ActivityScreenOrientation.LANDSCAPE : ActivityScreenOrientation.PORTRAIT;
value = importDefault(694) /* metro dependency 694: Dispatcher */;
value.dispatch({type: 'ACTIVITY_SCREEN_ORIENTATION_UPDATE', screenOrientation: r4});
}
function _fun82252() { // fn#82252, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10890:905, offset: 0x01ef0d24, size: 18 bytes, params: 1, frame: 11
env0_8(false);
}
function _fun82253() { // fn#82253, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10890:942, offset: 0x01ef0d36, size: 122 bytes, params: 1, frame: 14
var value2;
if (env0_7) {
setShowLoadingStateForLockingOrientation(false);
} else if (orientationLockState != null) {
setShowLoadingStateForLockingOrientation(false);
} else {
value2 = environment.__proto__;
if ((importDefault(10705) /* metro dependency 10705: doesOrientationMatchLockState */)(ConstantsModule.ActivityScreenOrientation, ReactNativeModule.View)) {
setShowLoadingStateForLockingOrientation(false);
} else {
setShowLoadingStateForLockingOrientation(true);
}
}
if (application != null) {
setOrientationLockState(application, orientationLockState);
}
}
function _fun82254() { // fn#82254, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10890:1039, offset: 0x01ef0db0, size: 58 bytes, params: 1, frame: 14
const value = environment.__proto__;
if ((importDefault(10705) /* metro dependency 10705: doesOrientationMatchLockState */)(ConstantsModule.ActivityScreenOrientation,
orientationLockState)) {
setShowLoadingStateForLockingOrientation(false);
}
}
function _fun82255() { // fn#82255, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10890:1095, offset: 0x01ef0dea, size: 34 bytes, params: 1, frame: 11
if (!(showLoadingIndicator || ReactNativeModule.ActivityIndicator)) {
env0_8(true);
}
}
}
function ActivityViewLoadingIndicator() { // fn#82256, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10890:1168, offset: 0x01ef0e0c, size: 69 bytes, params: 1, frame: 17
const styles = useStyles();
return (
<View style={styles.loadingContainer}>
<ActivityIndicator size="large" />
</View>
);
}
function BaseActivityView(a0) { // fn#82257, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10890:1286, offset: 0x01ef0e51, size: 133 bytes, params: 2, frame: 19
var r0;
var value;
var jsxRuntimeEnv0_12Binding;
if (a0.showLoadingIndicator) {
r0 = <ActivityViewLoadingIndicator />;
} else {
value = null;
if (a0.isResetting) {
r0 = value;
} else {
jsxRuntimeEnv0_12Binding = jsxRuntimeEnv0_12;
value = importDefault(10706) /* metro dependency 10706: WakeLock */;
value = ((Component) => <Component wakeLockKey={a0.wakeLockKey} />)(value);
value = (
<>
{value}
{a0.children}
</>
);
r0 = value;
}
}
return r0;
}
function EmbeddedActivityViewInner({channel, layoutMode, portraitSafeAreasConfig, landscapeSafeAreasConfig}) { // fn#82258, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10890:1490, offset: 0x01ef0ed6, size: 1004 bytes, params: 2, frame: 32
var r7;
var r14;
var r0;
var location;
var EmbeddedActivityWebView;
let value = undefined;
let env0_3 = value;
const embeddedActivitiesStoreBinding = EmbeddedActivitiesStore;
const currentEmbeddedActivity2 = embeddedActivitiesStoreBinding.getCurrentEmbeddedActivity();
const value4 = (UseCurrentEmbeddedApplication)();
const value5 = (FluxModule).useStateFromStores([embeddedActivitiesStoreBinding],
_fun82259, [value4]);
const [property, property2] = env0_3(env0_4.useState(true), 2);
object = {currentEmbeddedActivity: currentEmbeddedActivity2, channel: channel};
const currentEmbeddedActivity = object.currentEmbeddedActivity;
const channel2 = object.channel;
if (currentEmbeddedActivity == null) {
r14 = {instance_id: ''};
} else {
object = {};
object.instance_id = currentEmbeddedActivity.compositeInstanceId ?? currentEmbeddedActivity.launchId;
location = currentEmbeddedActivity.location;
object.location_id = location == null ? value : location.id;
object.launch_id = currentEmbeddedActivity.launchId;
if (currentEmbeddedActivity.proxyTicket != null) {
object.discord_proxy_ticket = currentEmbeddedActivity.proxyTicket;
}
r7 = channel2 != null && channel2.id != null;
r7 = r7 && channel2.id !== '';
if (r7) {
object.channel_id = channel2.id;
}
r7 = (channel2 == null ? value : channel2.guild_id) != null && (channel2 == null ? value : channel2.guild_id) !== '';
if (r7) {
object.guild_id = channel2 == null ? value : channel2.guild_id;
r14 = object;
} else {
r14 = object;
}
}
(UseDispatchOpenActivity)({connectedEmbeddedActivity: currentEmbeddedActivity2});
env0_4.useLayoutEffect(_fun82260, [layoutMode, currentEmbeddedActivity2]);
const value14 = env0_4.useCallback(_fun82261, [value4, currentEmbeddedActivity2]);
const id = value4 == null ? value : value4.id;
let r6 = currentEmbeddedActivity2 == null || (currentEmbeddedActivity2 == null ? value : currentEmbeddedActivity2.launchId) == null;
r6 = !r6 ? property : r6;
r6 = !r6 ? id == null : r6;
r6 = !r6 ? value4 == null : r6;
object = {orientationLockState: value5, showLoadingIndicator: r6,
setShowLoadingStateForLockingOrientation: property2, application: value4};
object.setOrientationLockState = (require(10703) /* metro dependency 10703: getDefaultOrientationLockState */).setOrientationLockState;
const value19 = useBaseActivityView(object);
const isResetting = value19.isResetting;
env0_3 = value19.setIsResetting;
if (currentEmbeddedActivity2 == null) {
r0 = null;
} else if (id == null) {
r0 = null;
} else {
object = {wakeLockKey: 'EmbeddedActivities', showLoadingIndicator: r6, isResetting: isResetting};
EmbeddedActivityWebView = importDefault(10709) /* metro dependency 10709: EmbeddedActivityWebView */;
value = (
<BaseActivityView {...object}>
<EmbeddedActivityWebView
onActivityCrash={function() {
setIsResetting(true);
global.setTimeout(_fun82263, 0);
}}
applicationId={id}
channelId={channel == null ? value : channel.id}
guildId={channel == null ? value : channel.guild_id}
activityUrl={currentEmbeddedActivity2.url}
currentEmbeddedActivity={currentEmbeddedActivity2}
activitySessionId={currentEmbeddedActivity2 == null ? value : currentEmbeddedActivity2.compositeInstanceId}
queryParams={r14}
onLoadError={value14}
allowPopups={(require(10716) /* metro dependency 10716: allowPopups */).allowPopups(value4)}
referrerPolicy="origin"
isPipOrGridMode={layoutMode === ActivityLayoutMode.PIP || layoutMode === ActivityLayoutMode.GRID}
webViewKey={(require(8092) /* metro dependency 8092: EmbeddedActivitiesNativeManager */).EMBEDDED_ACTIVITY_WEB_VIEW_KEY}
safeAreasConfig={value19.isLandscape ? landscapeSafeAreasConfig : portraitSafeAreasConfig}
ignoreSilentHardwareSwitch={!OBEY_SILENT_HARDWARE_SWITCH_APP_IDS.has(id)}
/>
</BaseActivityView>
);
r0 = value;
}
return r0;
function _fun82259() { // fn#82259, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10890:1689, offset: 0x01ef12c2, size: 47 bytes, params: 1, frame: 12
return env0_2 != null ? EmbeddedActivitiesStore.getOrientationLockStateForApp(env0_2.id) : undefined;
}
function _fun82260() { // fn#82260, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10890:2358, offset: 0x01ef12f1, size: 84 bytes, params: 1, frame: 13
var value2;
if (env0_1 != null) {
value2 = environment.__proto__;
(importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'ACTIVITY_LAYOUT_MODE_UPDATE',
layoutMode: layoutMode, applicationId: env0_1.applicationId});
}
}
function _fun82261() { // fn#82261, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10890:2501, offset: 0x01ef1345, size: 97 bytes, params: 1, frame: 16
let value = environment.__proto__;
value = undefined;
(importDefault(8092) /* metro dependency 8092: EmbeddedActivitiesNativeManager */).leaveActivity({location: env0_1 == null ? value : env0_1.location,
applicationId: env0_2 == null ? value : env0_2.id});
return value;
}
function onActivityCrash() { // fn#82262, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10890:3089, owner: EmbeddedActivityViewInner.onActivityCrash, offset: 0x01ef13a6, size: 43 bytes, params: 1, frame: 13
setIsResetting(true);
global.setTimeout(function() {
return setIsResetting(false);
}, 0);
function _fun82263() { // fn#82263, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10890:3112, offset: 0x01ef13d1, size: 18 bytes, params: 1, frame: 11
return setIsResetting(false);
}
}
}
}
global.__d(_fun82249, 10704, [57, 31, 27, 1378, 4237, 4238, 33, 4501, 10703, 1478, 694, 10705, 10706, 10701, 566,
10708, 8092, 10709, 10716,
2]) /* metro module 10704, dependencies: [57, 31, 27, 1378, 4237, 4238, 33, 4501, 10703, 1478, 694, 10705, 10706, 10701, 566, 10708, 8092, 10709, 10716, 2] */;