decord/source/modules/gif_picker/native/GIFPicker.tsx
github-actions e510164e6b chore: update source for alpha 346.2
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4759.js (118.4 MB)
2026-09-10 05:38:07 +00:00

247 lines
9.3 KiB
TypeScript

// Module ID: 10396
// Function ID: 10397
// Name: GIFPicker
// Dependencies: [32, 19, 17, 10397, 1074, 21, 4574, 10398, 1242, 6959, 10401, 12, 10404, 504, 9726, 10405, 10406, 10409, 10410, 10414, 2]
// Module 10396 (GIFPicker)
import AnalyticsUtilsDefault from "AnalyticsUtils" /* 1242 */;
import GIFPickerActionCreatorsAll from "GIFPickerActionCreators" /* 10398 */;
import gif_picker_GIFPickerUtils from "gif_picker/GIFPickerUtils" /* 10401 */;
import GifPickerUtils from "GifPickerUtils" /* 10404 */;
import GIFPickerSearchSuggestionsDefault from "GIFPickerSearchSuggestions" /* 10405 */;
import _slicedToArray from "module_32" /* 32 */;
import noop from "module_19" /* 19 */;
import GIFPickerViewStore from "GIFPickerViewStore" /* 10397 */;
require = fn;
const View = fn(17).View;
const Constants = fn(1074);
({ AnalyticEvents: closure_8, ChatInputComponentViewedTypes: closure_9, GIF_FETCH_LIMIT_IOS: c10, GIFPickerResultTypes: closure_11, TooltipNames: closure_12 } = Constants);
const jsxProd = fn(21);
({ jsx: map1, jsxs: closure_14 } = jsxProd);
const createStyles = fn(4574);
let closure_15 = createStyles.createStyles({ container: { flex: 1 } });
const size = fn(2);
const result = size.fileFinishedImporting("modules/gif_picker/native/GIFPicker.tsx");
export default noop.memo(function GIFPicker(bottomSheetRef) {
bottomSheetRef = bottomSheetRef.bottomSheetRef;
const channelId = bottomSheetRef.channelId;
const guildId = bottomSheetRef.guildId;
const initialQuery = bottomSheetRef.initialQuery;
let flag = bottomSheetRef.inActionSheet;
if (flag === undefined) {
flag = true;
}
const contentHorizontalPadding = bottomSheetRef.contentHorizontalPadding;
const onPressGIF = bottomSheetRef.onPressGIF;
c13 = undefined;
closure_15 = undefined;
({ selectedGifSrc, keyboardDismissMode } = bottomSheetRef);
const items = [channelId, guildId];
const effect = onPressGIF.useEffect(() => {
GIFPickerActionCreatorsAll.initializeSearch();
GIFPickerActionCreatorsAll.resetSearch();
if (null != channelId) {
const obj4 = { type: constants2.GIF, channel_id: tmp4, guild_id: guildId };
AnalyticsUtilsDefault.track(constants.CHAT_INPUT_COMPONENT_VIEWED, obj4);
}
}, items);
let tmp3 = channelId;
let obj = initialQuery;
const tmp4 = channelId(initialQuery[9])();
closure_6 = tmp4;
const tmp5 = contentHorizontalPadding(onPressGIF.useState(0), 2);
const first = tmp5[0];
closure_8 = tmp5[1];
const items1 = [tmp4, first, contentHorizontalPadding];
const callback = onPressGIF.useCallback((nativeEvent) => {
closure_8(nativeEvent.nativeEvent.layout.width);
}, []);
const memo = onPressGIF.useMemo(() => {
let num = 2;
if (closure_6) {
num = 3;
}
const obj = { columns: num, columnWidth: null };
let num2 = contentHorizontalPadding;
if (contentHorizontalPadding == null) {
num2 = 0;
}
const diff = first - 2 * num2;
const sum = diff + gif_picker_GIFPickerUtils.GIF_PICKER_GUTTER_SPACING;
obj.columnWidth = Math.max(0, sum / num - gif_picker_GIFPickerUtils.GIF_PICKER_GUTTER_SPACING);
return obj;
}, items1);
({ columns, columnWidth } = memo);
const ref = onPressGIF.useRef(null);
const tmp10 = contentHorizontalPadding(onPressGIF.useState(false), 2);
closure_10 = tmp10[1];
constants3 = onPressGIF.useRef("");
onPressGIF.useRef(false);
const tmp = closure_15();
[tmp12, c13] = contentHorizontalPadding(onPressGIF.useState(false), 2);
const tmp14 = contentHorizontalPadding(onPressGIF.useState(constants3.SEARCH), 2);
const first1 = tmp14[0];
closure_15 = tmp14[1];
const tmp16 = contentHorizontalPadding(onPressGIF.useState(""), 2);
const first2 = tmp16[0];
closure_17 = tmp17;
const items2 = [ref];
const callback1 = onPressGIF.useCallback(() => {
closure_10(false);
closure_15(constants3.SEARCH);
closure_17("");
GIFPickerActionCreatorsAll.resetSearch();
const current = ref.current;
if (current != null) {
current.blur();
}
}, items2);
const memo1 = onPressGIF.useMemo(() => bottomSheetRef(initialQuery[11]).debounce(guildId(initialQuery[7]).search, 200), []);
const tmp11 = contentHorizontalPadding(onPressGIF.useState(false), 2);
const favoriteGIFsMobile = bottomSheetRef(initialQuery[10]).useFavoriteGIFsMobile();
const favorites = favoriteGIFsMobile.favorites;
const items3 = [favorites, first2];
closure_20 = onPressGIF.useMemo(() => GifPickerUtils.filterFavoriteGIFsByQuery(favorites, first2), items3);
const obj2 = bottomSheetRef(initialQuery[10]);
const items4 = [first];
const stateFromStoresObject = bottomSheetRef(initialQuery[13]).useStateFromStoresObject(items4, () => {
if (first1 !== constants3.FAVORITES) {
resultItems = GIFPickerViewStore.getResultItems();
} else {
resultItems = closure_20;
}
return { resultItems, resultQuery: GIFPickerViewStore.getResultQuery() };
});
let resultItems = stateFromStoresObject.resultItems;
const resultQuery = stateFromStoresObject.resultQuery;
const items5 = [memo1, ref, resultQuery];
const callback2 = onPressGIF.useCallback((current) => {
let flag = arg1;
if (arg1 === undefined) {
flag = true;
}
if (ref.current !== current) {
ref.current = current;
closure_15(constants3.SEARCH);
const tmp21 = current.trim().length > 0;
let tmp2 = tmp21;
if (tmp2) {
tmp2 = resultQuery !== current;
}
_undefined(tmp2);
closure_10(tmp21);
if (flag) {
let search = memo1;
} else {
search = GIFPickerActionCreatorsAll.search;
}
let SEARCH = null;
if ("" !== current) {
SEARCH = tmp19.SEARCH;
}
search(current, SEARCH, !flag, limit);
if (!flag) {
current = ref.current;
if (current != null) {
current.setText(current);
}
}
tmp19 = constants3;
}
}, items5);
const items6 = [callback2, initialQuery];
const effect1 = onPressGIF.useEffect(() => {
if (!ref2.current) {
let tmp3 = null != initialQuery;
if (tmp3) {
tmp3 = str.trim().length > 0;
}
if (tmp3) {
tmp.current = true;
callback2(str, false);
}
}
}, items6);
const effect2 = onPressGIF.useEffect(() => {
channelId(initialQuery[14]).acknowledgeTooltip(ref2.GIF_PICKER_TOOLTIP);
const obj = channelId(initialQuery[14]);
const trendingSearchTerms = guildId(initialQuery[7]).fetchTrendingSearchTerms();
}, []);
const items7 = [resultQuery, ref];
const effect3 = onPressGIF.useEffect(() => {
if ("" !== resultQuery) {
const suggestions = GIFPickerActionCreatorsAll.fetchSuggestions(tmp);
}
const current = ref.current;
let text;
if (current != null) {
text = current.getText();
}
_undefined(resultQuery !== text);
}, items7);
const items8 = [callback2];
const items9 = [onPressGIF, resultItems.length, resultQuery];
const memo2 = onPressGIF.useMemo(() => map1(GIFPickerSearchSuggestionsDefault, {
onClickSuggestion(dependencyMap) {
return callback2(dependencyMap, false);
}
}), items8);
const items10 = [bottomSheetRef, callback2];
const callback3 = onPressGIF.useCallback((gifId, index) => {
GIFPickerActionCreatorsAll.trackSelectGIF({ type: constants3.SEARCH, index, offset: 0, limit, results: resultItems.length, totalResults: resultItems.length, query: resultQuery, gifId: gifId.id });
onPressGIF(gifId);
}, items9);
const callback4 = onPressGIF.useCallback((arg0, arg1) => {
if (arg0 === constants3.TRENDING_GIFS) {
closure_10(false);
closure_15(arg0);
const trendingGIFs = GIFPickerActionCreatorsAll.fetchTrendingGIFs(limit);
} else if (arg0 === tmp.FAVORITES) {
closure_10(false);
closure_15(arg0);
} else {
callback2(arg1, false);
}
const current = bottomSheetRef.current;
if (current != null) {
current.expandActionSheet();
}
}, items10);
let obj4 = { onLayout: callback, style: null, children: null };
const items11 = [tmp.container, ];
let tmp31 = null;
if (null != contentHorizontalPadding) {
const obj5 = { paddingHorizontal: contentHorizontalPadding };
tmp31 = obj5;
}
items11[1] = tmp31;
obj4.style = items11;
const items12 = [c13(tmp3(obj[16]), { categoryType: first1, columnWidth, onQueryClear: callback1, onQueryChange: callback2, onFavoritesQueryChange: tmp16[1], searchInputRef: ref }), ];
if (resultItems.length <= 0) {
if (!tmp10[0]) {
if (first2.length <= 0) {
const obj6 = { columns, onSelectCategory: callback4, favoritesCategory: null, inActionSheet: null };
let favoritesCategory;
if (true !== bottomSheetRef.hideFavorites) {
favoritesCategory = favoriteGIFsMobile.favoritesCategory;
}
obj6.favoritesCategory = favoritesCategory;
obj6.inActionSheet = flag;
items12[1] = tmp32(tmp3(obj[19]), obj6);
obj4.children = items12;
return first1(closure_6, obj4);
}
}
}
if (0 === resultItems.length) {
if (!tmp12) {
const obj7 = { categoryType: first1, inActionSheet: flag };
let tmp32Result = tmp32(tmp3(obj[17]), obj7);
}
}
tmp3 = tmp3(obj[18]);
obj = { columns, columnWidth, loading: tmp12, inActionSheet: flag, resultItems, onPressGIF: callback3, selectedGifSrc, keyboardDismissMode, ListFooterComponent: memo2 };
tmp32Result = tmp32(tmp3, obj);
});