Files
discord-decomp/modules/launchpad/native/LaunchPadSearchResultUser.tsx
T
2026-11-01 12:12:55 +02:00

107 lines
6.0 KiB
TypeScript

// Metro module 15820 (f15821).
import { useCallback, memo } from "react";
import AccessibilityStore from "../../a11y/AccessibilityStore";
import LocaleStore from "../../user_settings/LocaleStore";
import ChannelStore from "../../../stores/ChannelStore";
import PresenceStore from "../../../stores/PresenceStore";
import TypingStore from "../../../stores/TypingStore";
import UserGuildSettingsStore from "../../../stores/UserGuildSettingsStore";
import { StatusTypes } from "../../../Constants";
import { UnreadSetting } from "../../read_states/ReadStateConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import getLayoutStyles from "./shared/getLayoutStyles";
import ChannelActionCreators from "../../../actions/ChannelActionCreators";
import { useFontScale } from "../../screen/native/useFontScale";
import { useStateFromStores, useStateFromStoresObject } from "../../../_bundle/Module589";
import SnowflakeUtils from "../../../utils/SnowflakeUtils";
import { getRelativeTimestamp } from "../../notification_center/NotificationCenterUtils";
import renderChannelPressableWrapper from "./shared/renderChannelPressableWrapper";
import { PressableHighlight } from "../../../design/void/Pressables/native/Pressables";
import renderChannelWrapper from "./shared/renderChannelWrapper";
import UnreadBadge from "./shared/UnreadBadge";
import { Avatar } from "../../../design/void/native";
import isStreaming from "../../activities/utils/isStreaming";
import renderChannelContent from "./shared/renderChannelContent";
import UserUtils from "../../../utils/UserUtils";
import { ChannelRowPreview } from "../../main_tabs_v2/native/shared_components/ChannelRowPreview";
import { ChannelListLayoutTypes } from "../../main_tabs_v2/ChannelListLayoutTypes";
import renderChannelBadge from "./shared/renderChannelBadge";
import { useBaseChannelUnreadBadgeState } from "./shared/useChannelUnreadBadgeState";
import useMessagePreviews from "../../main_tabs_v2/useMessagePreviews";
let useStyles, UserResultWithChannel;
const UserResult = function UserResult(props) {
const user = props.user;
let comparator = props.comparator;
const { channel: channel2, lastMessage, unread = false, mentionCount = 0, muted = false, isTyping = false } = props;
const styles = useStyles();
const styles2 = getLayoutStyles();
const callback = useCallback(() => {
ChannelActionCreators.openPrivateChannel({
recipientIds: [user.id]
});
}, [user.id]);
const fontScale = useFontScale();
const stateFromStores2 = useStateFromStores([LocaleStore], () => LocaleStore.locale);
const stateFromStores3 = useStateFromStores([AccessibilityStore], () => AccessibilityStore.useReducedMotion);
const stateFromStoresObject = useStateFromStoresObject([PresenceStore], () => ({
isMobileOnline: PresenceStore.isMobileOnline(user.id),
isVROnline: PresenceStore.isVROnline(user.id),
status: PresenceStore.getStatus(user.id),
activities: PresenceStore.getActivities(user.id)
}));
const { isMobileOnline, isVROnline, status, activities } = stateFromStoresObject;
const r64 = lastMessage != null ? SnowflakeUtils.extractTimestamp(lastMessage.id) : void 0;
const lastMessageTimestampString = r64 != null ? getRelativeTimestamp(r64) : null;
const color = unread ? muted ? "text-muted" : "text-default" : "text-muted";
const r94 = [<UnreadBadge unread={unread} resolvedUnreadSetting={UnreadSetting.ALL_MESSAGES} />, <Avatar user={user} guildId={void 0} isMobileOnline={isMobileOnline} isVROnline={isVROnline} status={user.isSystemUser() ? null : status !== StatusTypes.OFFLINE ? status : null} streaming={isStreaming(activities)} style={styles2.icon.margin} size={styles2.icon.avatarSize} animate={stateFromStores3 ? !stateFromStores3 : isTyping || unread} typing={isTyping} autoStatusCutout />, ,];
if (comparator == null) {
comparator = UserUtils.getUserTag(user);
}
r94[2] = renderChannelContent({
name: comparator,
subtitle: lastMessage != null ? channel2 != null ? <ChannelRowPreview channel={channel2} message={lastMessage} color={color} muted={muted} layout={ChannelListLayoutTypes.COMPACT} /> : void 0 : void 0,
unread,
resolvedUnreadSetting: UnreadSetting.ALL_MESSAGES,
muted,
lastMessageTimestampString,
mentionCount,
mentionBadge: renderChannelBadge({
mentionCount,
locale: stateFromStores2
})
});
return renderChannelPressableWrapper(<PressableHighlight onPress={callback} underlayColor={styles.pressableUnderlayColor.backgroundColor} style={[styles.pressable, {
borderRadius: styles2.container.borderRadius
}]}>
{renderChannelWrapper(<>{r94}</>, {
fontScale
})}
</PressableHighlight>);
};
UserResultWithChannel = function UserResultWithChannel(props) {
const { user: user2, channel } = props;
const stateFromStores2 = useStateFromStores([UserGuildSettingsStore], () => UserGuildSettingsStore.isChannelMuted(void 0, channel.id));
const baseChannelUnreadBadgeState = useBaseChannelUnreadBadgeState(channel, stateFromStores2);
const { unread, mentionCount } = baseChannelUnreadBadgeState;
const stateFromStores3 = useStateFromStores([TypingStore], () => TypingStore.isTyping(channel.id, user2.id));
return <UserResult {...props} channel={channel} lastMessage={useMessagePreviews(channel, {
unread
})} unread={unread} mentionCount={mentionCount} muted={stateFromStores2} isTyping={stateFromStores3} />;
};
useStyles = createStyles({
pressable: {
flex: 1
},
pressableUnderlayColor: {
backgroundColor: Module712.colors.INTERACTIVE_BACKGROUND_ACTIVE
}
});
const r53 = memo(function(a0) {
const user3 = a0.user;
const stateFromStores = useStateFromStores([ChannelStore], () => ChannelStore.getDMFromUserId(user3.id));
const stateFromStores2 = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(stateFromStores));
return stateFromStores2 != null ? <UserResultWithChannel {...a0} channel={stateFromStores2} /> : <UserResult {...a0} />;
});
export default r53;