Files
discord-decomp/modules/keyboard/native/PortalKeyboardInlineComponent.ios.tsx
T
2026-11-01 12:12:55 +02:00

92 lines
3.8 KiB
TypeScript

// Metro module 11730 (f11731).
import { memo, useId, useRef, useLayoutEffect } from "react";
import { NativeModules, findNodeHandle } from "react-native";
import AccessibilityStore from "../../a11y/AccessibilityStore";
import useKeyboardType, { useKeyboardContextForType } from "./useKeyboardType";
import useSystemKeyboardHeight_native from "./useSystemKeyboardHeight.native";
import useKeyboardIsOpen from "./useKeyboardIsOpen";
import { KeyboardTypes } from "./KeyboardTypes";
import useMountEffect from "../../../hooks/useMountEffect";
import { PortalKeyboardUIStore, closePortalKeyboard, handlePortalKeyboardOpen, closePortalKeyboardRequest } from "./PortalKeyboardUIStore.native";
import { dismissKeyboard } from "../../../utils/native/ChatInputUtils";
import { PortalKeyboardState } from "./PortalKeyboard";
import { getKeyboardActionSheetHeight } from "../../action_sheet/native/useKeyboardActionSheetHeight";
const r23 = memo(function InlinePortalKeyboard({ channelId, messagesRef }) {
let field, field2, ref;
field = void 0;
field2 = void 0;
ref = void 0;
const id = useId();
const keyboardType = useKeyboardType();
let c19100_2 = keyboardType;
const systemKeyboardHeight_native = useSystemKeyboardHeight_native();
const keyboardIsOpen = useKeyboardIsOpen({
includeCustomKeyboard: false
});
let c19100_3 = keyboardIsOpen;
const keyboardContextForType = useKeyboardContextForType(KeyboardTypes.SYSTEM);
useMountEffect(() => () => {
const field3 = PortalKeyboardUIStore.getField("keyboard");
if (field3 != null && field3.handlerId === id) {
dismissKeyboard();
closePortalKeyboard();
}
});
field = PortalKeyboardUIStore.useField("keyboard");
field2 = PortalKeyboardUIStore.useField("state");
ref = useRef(false);
useLayoutEffect(() => {
L28: {
const current = ref.current;
if (field != null) {
if (field.handlerId != null && field.handlerId !== id) {
break L28;
}
if (field != null && field2 === PortalKeyboardState.REQUEST_OPEN) {
const current3 = messagesRef.current;
const r46 = current3 == null ? void 0 : current3.getChatRef();
if (r46 == null) {
break L28;
}
const r50 = findNodeHandle(r46.current);
if (r50 == null) {
break L28;
}
handlePortalKeyboardOpen(id);
ref.current = true;
NativeModules.DCDChatManager.customKeyboardWillShow(r50, getKeyboardActionSheetHeight().minimum, 0.25, 7);
break L28;
}
if (c19100_2 === KeyboardTypes.SYSTEM) {
if (keyboardContextForType.keyboardWillOpen && field2 !== PortalKeyboardState.REQUEST_CLOSE) {
let c27137_0 = setTimeout(closePortalKeyboardRequest, 250);
return () => clearTimeout(c27137_0);
}
closePortalKeyboard();
const current4 = messagesRef.current;
const r96 = current4 == null ? void 0 : current4.getChatRef();
if (r96 != null) {
const r100 = findNodeHandle(r96.current);
if (r100 != null) {
ref.current = false;
NativeModules.DCDChatManager.customKeyboardWillHide(r100, 0.25, 7);
}
}
}
} else if (!(c19100_3 || (current ? !current : !AccessibilityStore.systemPrefersCrossfades))) {
const current2 = messagesRef.current;
const r21 = current2 == null ? void 0 : current2.getChatRef();
if (r21 != null) {
const r25 = findNodeHandle(r21.current);
if (r25 != null) {
ref.current = false;
NativeModules.DCDChatManager.customKeyboardWillHide(r25, 0.25, 7);
}
}
}
}
}, [channelId, id, field, field2, keyboardType, messagesRef, keyboardContextForType, systemKeyboardHeight_native, keyboardIsOpen]);
return null;
});
export default r23;