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

395 lines
23 KiB
TypeScript

/* Metro module 11273; source: modules/chat/native/ChatView.tsx; dependencies: [31, 27, 4257, 1383, 1379, 4814, 661, 33, 4501, 697, 4015, 566, 1244, 5072, 5087, 6518, 11274, 11275, 4884, 6904, 9864, 5097, 11277, 11289, 11321, 11525, 11926, 477, 11954, 11955, 11790, 11959, 11962, 11340, 11965, 7704, 14, 8581, 11980, 1305, 11982, 11984, 11985, 12056, 2] */
import TTITracker from '../../tti_analytics/TTITracker.tsx'; /* Metro dependency 14 */
import Native from '../../../external/discord_common/js/packages/tokens/native.tsx'; /* Metro dependency 697 */
import ChannelStore from '../../../stores/ChannelStore.tsx'; /* Metro dependency 1379 */
import GatewayConnectionStore from '../../gateway/GatewayConnectionStore.tsx'; /* Metro dependency 4257 */
import MessageStore from '../../../stores/MessageStore.tsx'; /* Metro dependency 4814 */
import UseInitialValue from '../../../hooks/useInitialValue.tsx'; /* Metro dependency 6518 */
import LazyLoadedThreadManager from '../../threads/LazyLoadedThreadManager.tsx'; /* Metro dependency 6904 */
import UseIsSelectedResourceChannel from '../../guild_onboarding_home/useIsSelectedResourceChannel.tsx'; /* Metro dependency 11275 */
import ChatViewWrapper from './ChatViewWrapper.tsx'; /* Metro dependency 11277 */
import Messages from '../../messages/native/Messages.tsx'; /* Metro dependency 11321 */
import StartupProfiler from '../../app_startup/StartupProfiler.tsx'; /* Metro dependency 11340 */
import ChatInput from '../../chat_input/native/ChatInput.tsx'; /* Metro dependency 11525 */
import ChatBeginningRow from '../../../components_native/chat/ChatBeginningRow.tsx'; /* Metro dependency 11926 */
import ChatViewPopups from './ChatViewPopups.tsx'; /* Metro dependency 11965 */
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 PlatformUtilsModule from '../../../utils/PlatformUtils.tsx'; /* Metro dependency 477 */
import * as ConstantsModule from '../../../Constants.tsx'; /* Metro dependency 661 */
import * as IndexNativeModule from '../../../intl/index.native.tsx'; /* Metro dependency 1244 */
import * as NativeModule from '../../../design/void/native.tsx'; /* Metro dependency 1305 */
import * as ChannelRecordModule from '../../../records/ChannelRecord.tsx'; /* Metro dependency 1383 */
import * as CreateStylesModule from '../../../design/components/Styles/native/createStyles.tsx'; /* Metro dependency 4501 */
import * as TTIAnalyticsUtilsModule from '../../tti_analytics/native/TTIAnalyticsUtils.tsx'; /* Metro dependency 4884 */
import * as AgeGateUtilsModule from '../../age_gate/AgeGateUtils.tsx'; /* Metro dependency 5072 */
import * as AgeGateUtilsModule2 from '../../age_gate/native/AgeGateUtils.tsx'; /* Metro dependency 8581 */
import * as SummaryActionCreatorsModule from '../../summaries/SummaryActionCreators.tsx'; /* Metro dependency 9864 */
import * as StartupProfilerModule from '../../app_startup/StartupProfiler.tsx'; /* Metro dependency 11340 */
function _fun86088(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#86088, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11459:6, offset: 0x01f87236, size: 423 bytes, params: 8, frame: 23
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
let value = ReactModule;
const StyleSheet = (ReactNativeModule).StyleSheet;
const createStyles = CreateStylesModule.createStyles;
object = {};
const object2 = {flex: 1};
object2.borderTopWidth = StyleSheet.hairlineWidth;
const BORDER_SUBTLE = (Native).colors.BORDER_SUBTLE;
object2.borderTopColor = BORDER_SUBTLE;
object.empty = object2;
object.messages = {'flex': 1, 'overflow': 'hidden'};
const CHANNEL_BACKGROUND_DEFAULT = (Native).colors.CHANNEL_BACKGROUND_DEFAULT;
object.chat = {'backgroundColor': null, 'justifyContent': 'flex-start', 'overflow': 'hidden', 'flex': 1,
backgroundColor: CHANNEL_BACKGROUND_DEFAULT};
const env0_12 = Reflect.apply(createStyles, CreateStylesModule, [object]);
value = value.memo(ChatView);
(FileImportTrackerModule).fileFinishedImporting('modules/chat/native/ChatView.tsx');
exports.default = value;
function ChatView({alwaysRespectKeyboard, channelId, chatInputRef, disableGradient, guildId, HACK_fixModalInteraction, screenIndex, secondaryTextFieldRef, setNoExtractUI}) { // fn#86089, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11459:536, offset: 0x01f873dd, size: 1484 bytes, params: 2, frame: 34
var r7;
var r5;
var gatewayConnectionStoreBinding;
const EmptyState = (NativeModule).EmptyState;
const intl = (IndexNativeModule).intl;
const t = (IndexNativeModule).t;
alwaysRespectKeyboard = !(alwaysRespectKeyboard === undefined) && alwaysRespectKeyboard;
disableGradient = !(disableGradient === undefined) && disableGradient;
var value;
const styles = useStyles();
let binding = HACK_fixModalInteraction;
binding.useEffect(_fun86090, [channelId, alwaysRespectKeyboard]);
const channel = (require(566) /* metro dependency 566: flux */).useStateFromStores([ChannelStore], function() {
return ChannelStore.getChannel(channelId);
});
const value2 = binding.useMemo(_fun86092, [channel, channelId]);
const channelIsLoading = value2.channelIsLoading;
const channel2 = value2.channel;
const value3 = (AgeGateUtilsModule).useIsChannelContentGated(channel2);
const value5 = (require(5087) /* metro dependency 5087: SpoilerChannelUtils */).useGetSpoilerGatingChannelId(channel ?? null);
binding = HACK_fixModalInteraction;
const env0_10 = binding.useRef(channelId);
const value6 = binding.useRef(null);
const env0_12 = binding.useRef(null);
const env0_13 = (UseInitialValue)(_fun86093);
const value8 = (require(566) /* metro dependency 566: flux */).useStateFromStoresObject([MessageStore], _fun86094,
[channelId, (UseIsSelectedResourceChannel)(channelId)]);
const env0_15 = value8.shouldRenderPlaceholder;
const env0_16 = value8.shouldRenderBegginingRow;
let closure = _fun86095;
const env0_17 = binding.useCallback(closure, []);
const env0_18 = binding.useCallback(function(a0) {
var keyCommand = a0.nativeEvent.keyCommand;
var current = chatInputRef.current;
if (current != null) {
current.handlePressKey(keyCommand);
}
}, [chatInputRef]);
const env0_19 = binding.useCallback(_fun86097, [value6]);
const env0_20 = binding.useCallback(_fun86098, [value6]);
binding.useLayoutEffect(_fun86099, []);
binding.useEffect(_fun86100, [channelId]);
binding.useEffect(_fun86101, [channel2.id]);
binding.useEffect(function() {
return _fun86103;
}, []);
closure = renderMessagesWrapper;
const Profiles = (StartupProfilerModule).Profiles;
const ChatView = Profiles.ChatView;
const value9 = ((Component) => <Component channelId={channelId} guildId={guildId} />)(ChatViewPopups);
const r8 = (
disableGradient
? null
: ((Component) => <Component absolute />)(importDefault(7704) /* metro dependency 7704: ThemedGradient */)
);
const ChatViewV2 = ChatViewV;
const ageGateUtilsModule = AgeGateUtilsModule2;
if (ageGateUtilsModule.shouldNSFWGateGuild(guildId)) {
value = importDefault(11980) /* metro dependency 11980: NsfwGateChat */;
value = ((Component) => <Component />)(value);
ChatViewV2(value, 'NsfwGateChat');
r5 = value;
} else if (channelIsLoading) {
gatewayConnectionStoreBinding = GatewayConnectionStore;
if (gatewayConnectionStoreBinding.isConnected()) {
if (channelIsLoading) {
value = (
<EmptyState
style={styles.empty}
title={intl.string(t.ai6Lbr)}
body={intl.string(t['LTr+x9'])}
/>
);
ChatViewV2(value, 'EmptyState');
r7 = value;
} else if (value3) {
value = importDefault(11982) /* metro dependency 11982: GuildNSFW */;
value = ((Component) => <Component guildId={guildId} channelId={channelId} />)(value);
ChatViewV2(value, 'GuildNSFW');
r7 = value;
} else if (value5 == null) {
if (channel2.isDirectory()) {
value = importDefault(11985) /* metro dependency 11985: GuildDirectory */;
value = ((Component) => <Component channel={channel2} guildId={guildId} />)(value);
ChatViewV2(value, 'GuildDirectory');
r7 = value;
} else if (channel2.isForumLikeChannel()) {
value = importDefault(12056) /* metro dependency 12056: ForumChannel */;
value = ((Component) => <Component channel={channel2} />)(value);
ChatViewV2(value, 'ForumChannel');
r7 = value;
} else {
r7 = closure();
}
} else if (value5 != null) {
value = importDefault(11984) /* metro dependency 11984: ChannelSpoiler */;
value = ((Component) => <Component guildId={guildId} channelId={value5} key={channelId} />)(value);
ChatViewV2(value, 'ChannelSpoiler');
r7 = value;
} else if (channel2.isDirectory()) {
value = importDefault(11985) /* metro dependency 11985: GuildDirectory */;
value = ((Component) => <Component channel={channel2} guildId={guildId} />)(value);
ChatViewV2(value, 'GuildDirectory');
r7 = value;
} else if (channel2.isForumLikeChannel()) {
value = importDefault(12056) /* metro dependency 12056: ForumChannel */;
value = ((Component) => <Component channel={channel2} />)(value);
ChatViewV2(value, 'ForumChannel');
r7 = value;
} else {
r7 = closure();
}
r5 = r7;
} else {
r5 = closure();
}
} else {
if (channelIsLoading) {
value = (
<EmptyState
style={styles.empty}
title={intl.string(t.ai6Lbr)}
body={intl.string(t['LTr+x9'])}
/>
);
ChatViewV2(value, 'EmptyState');
r7 = value;
} else if (value3) {
value = importDefault(11982) /* metro dependency 11982: GuildNSFW */;
value = ((Component) => <Component guildId={guildId} channelId={channelId} />)(value);
ChatViewV2(value, 'GuildNSFW');
r7 = value;
} else if (value5 == null) {
if (channel2.isDirectory()) {
value = importDefault(11985) /* metro dependency 11985: GuildDirectory */;
value = ((Component) => <Component channel={channel2} guildId={guildId} />)(value);
ChatViewV2(value, 'GuildDirectory');
r7 = value;
} else if (channel2.isForumLikeChannel()) {
value = importDefault(12056) /* metro dependency 12056: ForumChannel */;
value = ((Component) => <Component channel={channel2} />)(value);
ChatViewV2(value, 'ForumChannel');
r7 = value;
} else {
r7 = closure();
}
} else if (value5 != null) {
value = importDefault(11984) /* metro dependency 11984: ChannelSpoiler */;
value = ((Component) => <Component guildId={guildId} channelId={value5} key={channelId} />)(value);
ChatViewV2(value, 'ChannelSpoiler');
r7 = value;
} else if (channel2.isDirectory()) {
value = importDefault(11985) /* metro dependency 11985: GuildDirectory */;
value = ((Component) => <Component channel={channel2} guildId={guildId} />)(value);
ChatViewV2(value, 'GuildDirectory');
r7 = value;
} else if (channel2.isForumLikeChannel()) {
value = importDefault(12056) /* metro dependency 12056: ForumChannel */;
value = ((Component) => <Component channel={channel2} />)(value);
ChatViewV2(value, 'ForumChannel');
r7 = value;
} else {
r7 = closure();
}
r5 = r7;
}
return (
<StartupProfiler profile={ChatView}>
{value9}
{r8}
{r5}
</StartupProfiler>
);
function _fun86090() { // fn#86090, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11459:747, offset: 0x01f879a9, size: 49 bytes, params: 1, frame: 11
var value;
if (!alwaysRespectKeyboard) {
value = environment.__proto__;
value = require(4015) /* metro dependency 4015: ChatInputUtils */;
value.dismissKeyboard();
}
}
function _fun86092() { // fn#86092, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11459:865, offset: 0x01f879da, size: 137 bytes, params: 1, frame: 20
var r3;
var value2;
var createChannelRecordBinding;
var object2;
var intl;
if (channel == null) {
value2 = environment.__proto__;
createChannelRecordBinding = createChannelRecord;
object2 = {};
object2.id = channelId;
object2.type = ChannelTypes.GUILD_TEXT;
intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
object2.name = intl.string((require(1244) /* metro dependency 1244: indexNative */).t.ZTNur7);
r3 = createChannelRecordBinding(object2);
} else {
r3 = channel;
}
return {channel: r3, channelIsLoading: channel == null};
}
function _fun86093() { // fn#86093, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11459:1185, offset: 0x01f87a63, size: 47 bytes, params: 1, frame: 11
let value = environment.__proto__;
value = importDefault(11274) /* metro dependency 11274: VisibleMessagesWindowHandler */;
const value2 = Object.create(value.prototype, {constructor: {value: value}});
value = new value();
return value instanceof Object ? value : value2;
}
function _fun86094() { // fn#86094, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11459:1260, offset: 0x01f87a92, size: 93 bytes, params: 1, frame: 14
const value = environment.__proto__;
const messages = MessageStore.getMessages(channelId);
return {shouldRenderPlaceholder: messages.length === 0 && (messages.loadingMore || !messages.ready),
shouldRenderBegginingRow: !messages.hasMoreBefore && !env0_14};
}
function _fun86095(a0) { // fn#86095, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11459:1489, offset: 0x01f87aef, size: 36 bytes, params: 2, frame: 11
const current = env0_12.current;
if (current != null) {
current.onChatViewScrolled(a0);
}
}
function _fun86097() { // fn#86097, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11459:1671, offset: 0x01f87b45, size: 32 bytes, params: 1, frame: 9
const current = JsxRuntimeModule.Fragment.current;
if (current != null) {
current.scrollToNewMessages();
}
}
function _fun86098() { // fn#86098, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11459:1751, offset: 0x01f87b65, size: 32 bytes, params: 1, frame: 9
const current = JsxRuntimeModule.Fragment.current;
if (current != null) {
current.jumpToPresent();
}
}
function _fun86099() { // fn#86099, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11459:1827, offset: 0x01f87b85, size: 37 bytes, params: 1, frame: 11
const value = environment.__proto__;
return (TTIAnalyticsUtilsModule).trackAppUIViewed();
}
function _fun86100() { // fn#86100, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11459:1877, offset: 0x01f87baa, size: 72 bytes, params: 1, frame: 14
const value = environment.__proto__;
const defaultImport = LazyLoadedThreadManager;
const loadThread = defaultImport.loadThread;
const channelIdBinding = channelId;
Reflect.apply(loadThread, defaultImport, [channelIdBinding]);
(SummaryActionCreatorsModule).fetchSummaries(channelIdBinding);
}
function _fun86101() { // fn#86101, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11459:1952, offset: 0x01f87bf2, size: 26 bytes, params: 1, frame: 2
env0_10.current = channel.id;
}
function _fun86102() { // fn#86102, offset: 0x01f87c0c, size: 11 bytes, params: 1, frame: 1
return _fun86103;
function _fun86103() { // fn#86103, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11459:1999, offset: 0x01f87c17, size: 50 bytes, params: 1, frame: 12
let value = environment.__proto__.__proto__;
value = require(5097) /* metro dependency 5097: ReadStateActionCreators */;
value.clearOldestUnreadMessageId(env1_10.current);
}
}
function renderMessagesWrapper() { // fn#86104, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11459:2085, owner: ChatView.renderMessagesWrapper, offset: 0x01f87c49, size: 725 bytes, params: 1, frame: 27
let value = environment.__proto__;
const jsxRuntimeEnv1_11Binding = jsxRuntimeEnv1_11;
const defaultImportProps = {style: styles.messages};
let channelIdBinding = channelId;
defaultImportProps.channelId = channelIdBinding;
defaultImportProps.stickyHeader = ((Component) => <Component channel={channel} ref={env0_12} scrollToNewMessages={env0_19} />)(importDefault(11289) /* metro dependency 11289: ChatViewStickyHeader */);
const screenIndexBinding = screenIndex;
const chatInputRefBinding = chatInputRef;
const items2 = [
<Messages
alwaysRespectKeyboard={alwaysRespectKeyboard}
channel={channel}
screenIndex={screenIndexBinding}
chatInputRef={chatInputRefBinding}
HACK_fixModalInteraction={HACK_fixModalInteraction}
isResourceChannel={env0_14}
onPressKey={env0_18}
onScroll={env0_17}
ref={JsxRuntimeModule.Fragment}
style={styles.chat}
visibleMessagesWindowHandler={env0_13}
>
{((Component) => <Component ref={chatInputRefBinding} channel={channel} isResourceChannel={env0_14} screenIndex={screenIndexBinding} secondaryTextFieldRef={secondaryTextFieldRef} setNoExtractUI={setNoExtractUI} onJumpToPresent={env0_20} />)(ChatInput)}
{((Component) => <Component channelId={channelIdBinding} guildId={channel.getGuildId()} shouldRender={shouldRenderBegginingRow} />)(ChatBeginningRow)}
</Messages>,
];
const isAndroid2 = PlatformUtilsModule.isAndroid();
const value5 = null;
items2[1] = (
isAndroid2
? value5
: ((Component) => <Component channelId={channel.id} messagesRef={JsxRuntimeModule.Fragment} />)(importDefault(11954) /* metro dependency 11954: PortalKeyboardInlineComponentIos */)
);
items2[2] = (
shouldRenderPlaceholder
? ((Component) => <Component screenIndex={screenIndex} />)(importDefault(11955) /* metro dependency 11955: ChatPlaceholder */)
: value5
);
items2[3] = (
PlatformUtilsModule.isAndroid()
? ((Component) => <Component channelId={channelId} screenIndex={screenIndex} onJumpToPresent={env0_20} />)(importDefault(11790) /* metro dependency 11790: JumpToPresentButton */)
: value5
);
const items3 = [
<ChatViewWrapper {...defaultImportProps}>
{items2}
</ChatViewWrapper>,
];
value = importDefault(11959) /* metro dependency 11959: ChannelSafeAreaBottomAndroid */;
channelIdBinding = channelId;
items3[1] = ((Component) => <Component channelId={channelIdBinding} />)(value);
items3[2] = ((Component) => <Component channelId={channelIdBinding} />)(importDefault(11962) /* metro dependency 11962: VoiceMessageOverlay */);
return (
<>
{items3}
</>
);
}
function ChatViewV(a0, a1) { // fn#86105, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11459:2998, owner: ChatView.V, offset: 0x01f87f1e, size: 44 bytes, params: 3, frame: 11
const value = environment.__proto__;
(TTITracker).setInterstitial(a1);
return a0;
}
}
}
global.__d(_fun86088, 11273, [31, 27, 4257, 1383, 1379, 4814, 661, 33, 4501, 697, 4015, 566, 1244, 5072, 5087, 6518,
11274, 11275, 4884, 6904, 9864, 5097, 11277, 11289, 11321, 11525, 11926, 477, 11954, 11955, 11790, 11959, 11962,
11340, 11965, 7704, 14, 8581, 11980, 1305, 11982, 11984, 11985, 12056,
2]) /* metro module 11273, dependencies: [31, 27, 4257, 1383, 1379, 4814, 661, 33, 4501, 697, 4015, 566, 1244, 5072, 5087, 6518, 11274, 11275, 4884, 6904, 9864, 5097, 11277, 11289, 11321, 11525, 11926, 477, 11954, 11955, 11790, 11959, 11962, 11340, 11965, 7704, 14, 8581, 11980, 1305, 11982, 11984, 11985, 12056, 2] */;