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

222 lines
13 KiB
TypeScript

/* Metro module 14536; source: modules/guild_sidebar/native/ChannelItem.tsx; dependencies: [29, 31, 27, 4396, 3793, 1878, 661, 1386, 4865, 33, 4501, 697, 6235, 11846, 1423, 5475, 14537, 6686, 6647, 566, 1305, 6632, 14538, 4805, 1230, 2] */
import ObjectWithoutProperties from '../../../by-id/module-00029-ObjectWithoutProperties.js'; /* Metro dependency 29 */
import Native from '../../../external/discord_common/js/packages/tokens/native.tsx'; /* Metro dependency 697 */
import UserStore from '../../../stores/UserStore.tsx'; /* Metro dependency 1878 */
import RelationshipStore from '../../../stores/RelationshipStore.tsx'; /* Metro dependency 3793 */
import PresenceStore from '../../../stores/PresenceStore.tsx'; /* Metro dependency 4396 */
import UseChannelRoleSubscriptionStatus from '../../guild_role_subscriptions/useChannelRoleSubscriptionStatus.tsx'; /* Metro dependency 6632 */
import BaseChannelItem from './BaseChannelItem.tsx'; /* Metro dependency 11846 */
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 ConstantsModule from '../../../Constants.tsx'; /* Metro dependency 661 */
import * as NativeModule from '../../../design/void/native.tsx'; /* Metro dependency 1305 */
import * as ChannelConstantsModule from '../../channel/ChannelConstants.tsx'; /* Metro dependency 1386 */
import * as CreateStylesModule from '../../../design/components/Styles/native/createStyles.tsx'; /* Metro dependency 4501 */
import * as UseChannelNameModule from '../../channel/useChannelName.tsx'; /* Metro dependency 4805 */
import * as ReadStateConstantsModule from '../../read_states/ReadStateConstants.tsx'; /* Metro dependency 4865 */
import * as LegacyTokensModule from '../../../design/migrations/native/LegacyTokens.tsx'; /* Metro dependency 6235 */
import * as BaseChannelItemModule from './BaseChannelItem.tsx'; /* Metro dependency 11846 */
function _fun109989(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#109989, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14733:6, offset: 0x023647d1, size: 594 bytes, params: 8, frame: 26
const env0_0 = require;
const getChannelMode2 = getChannelMode;
const env0_3 = ['channel', 'subtitle', 'hideIcon', 'children', 'textStyle', 'channelInfo', 'onPress'];
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
let value = ReactModule;
const ChannelTypes = ConstantsModule.ChannelTypes;
const Set = global.Set;
const GUILD_VOICE = ChannelTypes.GUILD_VOICE;
const GUILD_STAGE_VOICE = ChannelTypes.GUILD_STAGE_VOICE;
const set = new Set([GUILD_VOICE, GUILD_STAGE_VOICE]);
const createStyles = CreateStylesModule.createStyles;
object = {};
const GREEN_360 = (Native).unsafe_rawColors.GREEN_360;
object.channelIconLive = {tintColor: GREEN_360};
object.dmAvatar = {marginRight: 8};
const BACKGROUND_BASE_LOW = (Native).colors.BACKGROUND_BASE_LOW;
object.avatarStatus = {backgroundColor: BACKGROUND_BASE_LOW};
object.groupDmAvatar = {'width': 20, 'height': 20, 'borderRadius': 10, 'marginRight': 8};
object.channelInfoContainer = {paddingStart: 4};
const DARK_393C42_LIGHT_DEE0E4 = (LegacyTokensModule).DARK_393C42_LIGHT_DEE0E4;
object.avatarStatusSelected = {backgroundColor: DARK_393C42_LIGHT_DEE0E4};
const env0_16 = Reflect.apply(createStyles, CreateStylesModule, [object]);
value = value.memo(_fun109995);
(FileImportTrackerModule).fileFinishedImporting('modules/guild_sidebar/native/ChannelItem.tsx');
exports.default = value;
exports.getChannelMode = getChannelMode2;
function getChannelMode(a0) { // fn#109990, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14733:772, offset: 0x02364a23, size: 333 bytes, params: 2, frame: 16
const ChannelModes = (BaseChannelItemModule).ChannelModes;
const muted = a0.muted;
const selected = a0.selected;
const unread = a0.unread;
return selected ? a0.channel.isGuildVocal() ? unread ? ChannelModes.UNREAD_IMPORTANT : ChannelModes.RELEVANT : ChannelModes.SELECTED : a0.locked ? ChannelModes.LOCKED : muted ? ChannelModes.MUTED : unread ? a0.resolvedUnreadSetting === UnreadSetting.ALL_MESSAGES ? ChannelModes.UNREAD_IMPORTANT : ChannelModes.UNREAD_LESS_IMPORTANT : ChannelModes.DEFAULT;
}
function ChannelIcon_109991({channel, locked, isRulesChannel, isChannelLive, selected, mode}) { // fn#109991, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14733:1206, offset: 0x02364b70, size: 495 bytes, params: 2, frame: 26
var r9;
var r11;
var object;
var channelIcon;
var channelIconComponent;
var defaultImport2;
var BookCheckIcon;
const styles = useStyles();
let type = channel.type;
const DM = ChannelTypes.DM;
if (type === DM) {
return <DMChannelIcon userId={channel.getRecipientId()} selected={selected != null && selected} />;
}
type = channel.type;
const GROUP_DM = ChannelTypes.GROUP_DM;
if (type === GROUP_DM) {
var defaultImport = importDefault(1423) /* metro dependency 1423: AvatarUtils */;
var getChannelIconSource = defaultImport.getChannelIconSource;
object = {};
object.id = channel.id;
object.icon = channel.icon;
object.applicationId = channel.getApplicationId();
object.size = 20;
var value3 = Reflect.apply(getChannelIconSource, defaultImport, [object]);
if (value3 != null) {
return ((Component) => <Component style={styles.groupDmAvatar} source={value3} />)(importDefault(5475) /* metro dependency 5475: FastImage */);
}
}
if (isRulesChannel) {
defaultImport2 = importDefault(14537) /* metro dependency 14537 */;
BookCheckIcon = (require(6686) /* metro dependency 6686: BookCheckIcon */).BookCheckIcon;
r9 = defaultImport2;
r11 = BookCheckIcon;
} else {
channelIcon = (require(6647) /* metro dependency 6647: ChannelUtils */).getChannelIcon(channel,
{isRulesChannel: false, locked: locked});
channelIconComponent = (require(6647) /* metro dependency 6647: ChannelUtils */).getChannelIconComponent(channel,
{isRulesChannel: false, locked: locked});
r9 = channelIcon;
r11 = channelIconComponent;
}
const BaseChannelIcon = (BaseChannelItemModule).BaseChannelIcon;
return (
<BaseChannelIcon
mode={mode}
source={r9}
isChannelLive={isChannelLive}
style={isChannelLive ? styles.channelIconLive : undefined}
{...r11 != null ? {IconComponent: r11} : {}}
/>
);
}
function DMChannelIcon({userId, selected}) { // fn#109992, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14733:1905, offset: 0x02364d5f, size: 279 bytes, params: 2, frame: 24
const styles = useStyles();
const value2 = (require(566) /* metro dependency 566: flux */).useStateFromStores([UserStore], function() {
return UserStore.getUser(userId);
}, [userId]);
const {status, isMobileOnline,
isVROnline} = (require(566) /* metro dependency 566: flux */).useStateFromStoresObject([PresenceStore],
function() {
var object = {};
var presenceStoreBinding = PresenceStore;
var userIdBinding = userId;
object.status = presenceStoreBinding.getStatus(userIdBinding);
object.isMobileOnline = PresenceStore.isMobileOnline(userIdBinding);
object.isVROnline = PresenceStore.isVROnline(userIdBinding);
return object;
}, [userId]);
const Avatar = (NativeModule).Avatar;
const AvatarSizes = (NativeModule).AvatarSizes;
const XSMALL_20 = AvatarSizes.XSMALL_20;
return (
<Avatar
user={value2}
guildId={undefined}
size={XSMALL_20}
style={styles.dmAvatar}
status={status}
isMobileOnline={isMobileOnline}
isVROnline={isVROnline}
statusStyle={[styles.avatarStatus, selected && styles.avatarStatusSelected]}
/>
);
}
function _fun109995(a0) { // fn#109995, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14733:2414, offset: 0x02364ebf, size: 506 bytes, params: 2, frame: 32
const styles = useStyles();
const channel = a0.channel;
const subtitle = a0.subtitle;
const hideIcon = a0.hideIcon;
const children = a0.children;
const textStyle = a0.textStyle;
const channelInfo = a0.channelInfo;
const env0_1 = a0.onPress;
const value2 = ObjectWithoutProperties(a0, env0_3);
const {isSubscriptionGated,
needSubscriptionToAccess} = (UseChannelRoleSubscriptionStatus)(channel.id);
const channelMode = getChannelMode(a0);
const value5 = null;
const r7 = (
value5 != channelInfo || isSubscriptionGated
? (
<View style={styles.channelInfoContainer}>
{channelInfo}
{
isSubscriptionGated
? ((Component) => <Component locked={needSubscriptionToAccess} />)(importDefault(14538) /* metro dependency 14538: GuildRoleSubscriptionGatedChannelIcon */)
: value5
}
</View>
)
: value5
);
const object = {mode: channelMode};
const ChannelModes = (require(11846) /* metro dependency 11846: BaseChannelItem */).ChannelModes;
const UNREAD_IMPORTANT = ChannelModes.UNREAD_IMPORTANT;
object.unread = channelMode === UNREAD_IMPORTANT || channelMode === (require(11846) /* metro dependency 11846: BaseChannelItem */).ChannelModes.UNREAD_LESS_IMPORTANT;
object.hideIcon = hideIcon;
const BaseChannelName = (require(11846) /* metro dependency 11846: BaseChannelItem */).BaseChannelName;
object.name = (
<BaseChannelName
mode={channelMode}
name={UseChannelNameModule.computeChannelName(channel, UserStore, RelationshipStore)}
subtitle={subtitle}
textStyle={textStyle}
/>
);
object.icon = <ChannelIcon_109991 {...a0} {...{['mode']: channelMode}} />;
object.channelInfo = r7;
object.onPress = onPress_109996;
copyDataProperties(object, value2, undefined);
return (
<BaseChannelItem {...object}>
{children}
</BaseChannelItem>
);
function onPress_109996(a0) { // fn#109996, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14733:3022, offset: 0x023650b9, size: 137 bytes, params: 2, frame: 15
var value2;
var binding;
var moduleValue;
if (needSubscriptionToAccess) {
value2 = environment.__proto__;
binding = env1_15;
if (binding.has(channel.type)) {
moduleValue = require(1230) /* metro dependency 1230: router_utils */;
moduleValue.transitionTo(Routes.CHANNEL(channel.guild_id, StaticChannelRoute.ROLE_SUBSCRIPTIONS));
} else if (onPress != null) {
onPress(a0);
}
} else if (onPress != null) {
onPress(a0);
}
}
}
}
global.__d(_fun109989, 14536, [29, 31, 27, 4396, 3793, 1878, 661, 1386, 4865, 33, 4501, 697, 6235, 11846, 1423,
5475, 14537, 6686, 6647, 566, 1305, 6632, 14538, 4805, 1230,
2]) /* metro module 14536, dependencies: [29, 31, 27, 4396, 3793, 1878, 661, 1386, 4865, 33, 4501, 697, 6235, 11846, 1423, 5475, 14537, 6686, 6647, 566, 1305, 6632, 14538, 4805, 1230, 2] */;