This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

@@ -0,0 +1,175 @@
// Metro module 11348 (f11349).
import { useMemo, useState, useRef, useEffect, useCallback } from "react";
import { View } from "react-native";
import ApplicationCommandAutocompleteStore from "../../../../application_commands/ApplicationCommandAutocompleteStore";
import GuildStore from "../../../../../stores/GuildStore";
import { AutoCompleteResultTypes } from "../../../../../Constants";
import { AUTOCOMPLETE_OPTION_DEBOUNCE_TIME } from "../../../../application_commands/ApplicationCommandConstants";
import Module12 from "../../../../../_bundle/Module12";
import executeCommand from "../../../../application_commands/executeCommand";
import { createStyles } from "../../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../../_bundle/Module712";
import { useStateFromStoresObject } from "../../../../../_bundle/defaultAreStatesEqual";
import ActionSheetActionCreators from "../../../../action_sheet/native/ActionSheetActionCreators";
import { AppLauncherCommandOptionActionSheet } from "../AppLauncherCommandOptionActionSheet";
import { AppLauncherListSearchBar, AppLauncherListEmptyState, AppLauncherList } from "../../base_components/AppLauncherList";
import { intl, t } from "../../../../../intl/index.native";
import Module38 from "../../../../../_bundle/Module38";
import { TableRow } from "../../../../../design/components/TableRow/native/TableRow.native";
import { match } from "../../../../../_bundle/Module4389";
import { Text } from "../../../../../design/components/Text/native/Text";
import { EmptyState } from "../../../../../design/void/native";
import Module11345 from "../../../../../_bundle/Module11345";
let c7706_11, useStyles, AutocompleteFailedEmptyState;
const Item = function Item({ item, index, choices, onChoiceSelect }) {
let styles, memo;
styles = void 0;
memo = void 0;
const ListItem2 = function ListItem(props) {
return <TableRow label={props.label} onPress={props.onPress} start={index === 0} end={index === choices.length - 1} />;
};
Module38(item.type === AutoCompleteResultTypes.CHOICE || item.type === AutoCompleteResultTypes.CHOICE_LOADING || item.type === AutoCompleteResultTypes.LABEL, "Invalid autocomplete result type");
styles = useStyles();
memo = useMemo(() => 100 * Math.random() + 50, []);
return match(item).with({
type: AutoCompleteResultTypes.CHOICE
}, (a0) => {
return <ListItem2 label={<Text lineClamp={1} variant="text-md/normal" color="mobile-text-heading-primary">{a0.choice.displayName}</Text>} onPress={() => {
if (onChoiceSelect != null) {
onChoiceSelect(a0.choice);
}
ActionSheetActionCreators.hideActionSheet();
}} />;
}).with({
type: AutoCompleteResultTypes.LABEL
}, (a0) => {
return <ListItem2 label={<Text lineClamp={1} variant="text-md/normal" color="mobile-text-heading-primary">
"
{a0.label}
"
</Text>} onPress={() => {
if (onChoiceSelect != null) {
onChoiceSelect({
name: a0.label,
value: a0.label,
displayName: a0.label
});
}
ActionSheetActionCreators.hideActionSheet();
}} />;
}).with({
type: AutoCompleteResultTypes.CHOICE_LOADING
}, () => <ListItem2 label={<View style={styles.commandChoiceLoadingContainer}>
<View style={[styles.commandChoiceLoadingItem, {
width: memo
}]} />
</View>} />).exhaustive();
};
AutocompleteFailedEmptyState = function AutocompleteFailedEmptyState() {
return <EmptyState style={useStyles().emptyState} lightSource={Module11345} darkSource={Module11345} title={intl.string(t.rTAbPn)} />;
};
c7706_11 = Module12.debounce(executeCommand, AUTOCOMPLETE_OPTION_DEBOUNCE_TIME, {
leading: true,
trailing: true
});
useStyles = createStyles({
commandChoiceLoadingContainer: {
flex: 1,
justifyContent: "center"
},
commandChoiceLoadingItem: {
backgroundColor: Module712.colors.BACKGROUND_MOD_MUTED,
height: 16,
borderRadius: Module712.radii.lg,
alignSelf: "flex-start"
},
emptyState: {
backgroundColor: "transparent"
}
});
export default function AppLauncherAutocompleteActionSheet(props) {
let autocompleteResults, lastErrored, memo2;
const { option, initChoice, onChoiceSelect: onChoiceSelect2, onDismissAutocompleteSheet, channel, activeCommand, optionValues } = props;
autocompleteResults = void 0;
lastErrored = void 0;
memo2 = void 0;
let r6 = initChoice?.name;
if (r6 == null) {
r6 = "";
}
const [state, onChange] = useState(r6);
const ref = useRef(null);
const stateFromStoresObject = useStateFromStoresObject([ApplicationCommandAutocompleteStore], () => ({
autocompleteResults: ApplicationCommandAutocompleteStore.getAutocompleteChoices(channel.id, option.name, state),
lastErrored: ApplicationCommandAutocompleteStore.getLastErrored(channel.id)
}), [channel.id, option.name, state]);
autocompleteResults = stateFromStoresObject.autocompleteResults;
let lastErrored2 = stateFromStoresObject.lastErrored;
lastErrored = lastErrored2;
memo2 = useMemo(() => {
const r2 = [];
if (state !== "") {
r2.push({
type: AutoCompleteResultTypes.LABEL,
label: state
});
}
if (autocompleteResults == null && !lastErrored) {
r2.push.apply(r2, [...new Array(4).fill({
type: AutoCompleteResultTypes.CHOICE_LOADING
})]);
} else if (autocompleteResults != null) {
r2.push.apply(r2, [...autocompleteResults.map((autocompleteResult) => ({
type: AutoCompleteResultTypes.CHOICE,
choice: autocompleteResult
}))]);
}
return r2;
}, [state, autocompleteResults, lastErrored]);
let r44 = memo2.length === 0 && !lastErrored;
useEffect(() => {
c7706_11({
command: activeCommand,
optionValues,
context: {
channel,
guild: GuildStore.getGuild(channel.guild_id),
autocomplete: {
name: option.name,
query: state
}
}
});
const current = ref.current;
if (current != null) {
current.scrollToOffset({
offset: 0,
animated: false
});
}
}, [channel, option.name, activeCommand, optionValues, state]);
const callback = useCallback((a0) => <Item item={a0.item} index={a0.index} onChoiceSelect={onChoiceSelect2} choices={memo2} />, [onChoiceSelect2, memo2]);
const callback2 = useCallback(() => {
if (state !== "") {
if (onChoiceSelect2 != null) {
onChoiceSelect2({
name: state,
value: state,
displayName: state
});
}
ActionSheetActionCreators.hideActionSheet();
}
}, [onChoiceSelect2, state]);
const r78 = [<AppLauncherListSearchBar placeholder={intl.string(t.Wuie9L)} onChange={onChange} autoFocus returnKeyType="done" onSubmitEditing={callback2} />, , , ,];
if (r44) {
r44 = <AppLauncherListEmptyState />;
}
r78[1] = r44;
r78[2] = <AppLauncherList ref={ref} keyExtractor={(item, index) => `${item.type === AutoCompleteResultTypes.CHOICE ? item.choice.name : "placeholder"}_${index}`} data={memo2} renderItem={callback} scrollEnabled />;
if (lastErrored) {
lastErrored2 = <AutocompleteFailedEmptyState />;
}
r78[3] = lastErrored2;
return <AppLauncherCommandOptionActionSheet option={option} onDismiss={onDismissAutocompleteSheet}>{r78}</AppLauncherCommandOptionActionSheet>;
};
@@ -0,0 +1,79 @@
// Metro module 11347 (f11348).
import { useState } from "react";
import { Fonts } from "../../../../../Constants";
import { createStyles } from "../../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../../_bundle/Module712";
import { dismissGlobalKeyboard } from "../../../../../utils/native/KeyboardManagerUtils";
import ActionSheetActionCreators from "../../../../action_sheet/native/ActionSheetActionCreators";
import { useAnimationDelayedAutoFocus } from "../../hooks/useAnimationDelayedAutoFocus";
import { PressableOpacity } from "../../../../../design/void/Pressables/native/Pressables";
import { Text } from "../../../../../design/components/Text/native/Text";
const useStyles = createStyles({
container: {
width: "100%",
backgroundColor: Module712.colors.INPUT_BACKGROUND_DEFAULT,
borderRadius: Module712.radii.lg,
padding: 12,
borderWidth: 2,
borderColor: "transparent",
flexDirection: "row",
alignItems: "center"
},
hasError: {
borderColor: Module712.colors.BORDER_FEEDBACK_CRITICAL,
padding: 12
},
inputText: {
fontSize: 16,
alignSelf: "center",
fontFamily: Fonts.PRIMARY_MEDIUM,
color: Module712.colors.TEXT_DEFAULT
}
});
export default function AppLauncherAutocompleteOption(props) {
let state, setState;
const { style, option, onSelect, onOpenAutocompleteSheet, onDismissAutocompleteSheet, channel, activeCommand, optionValues, initialValue, autoFocus } = props;
let hasError = props.hasError;
state = void 0;
setState = void 0;
const onPress = function onPress() {
if (onOpenAutocompleteSheet != null) {
onOpenAutocompleteSheet();
}
dismissGlobalKeyboard();
ActionSheetActionCreators.openLazy(import("./AppLauncherAutocompleteActionSheet"), "AppLauncherAutocompleteActionSheet", {
option,
initChoice: state,
onChoiceSelect: (a0) => {
setState(a0);
onSelect(a0);
},
channel,
activeCommand,
onDismissAutocompleteSheet,
optionValues: optionValues.current
});
};
[state, setState] = useState(() => {
if (initialValue != null && initialValue.type === "text" && initialValue.text !== "") {
return {
displayName: initialValue.text,
name: initialValue.text,
value: initialValue.text
};
}
});
const styles = useStyles();
useAnimationDelayedAutoFocus(autoFocus, onPress);
const style2 = [styles.container, , ,];
if (hasError) {
hasError = styles.hasError;
}
style2[1] = hasError;
style2[2] = style;
return <PressableOpacity onPress={onPress} style={style2}>
<Text variant="text-md/normal" style={styles.inputText}>
{state != null ? state.displayName : " "}
</Text>
</PressableOpacity>;
};