diff --git a/src/usecase/buffers/ui/BufferContainer.tsx b/src/usecase/buffers/ui/BufferContainer.tsx index 517fa92..a9ce1e4 100644 --- a/src/usecase/buffers/ui/BufferContainer.tsx +++ b/src/usecase/buffers/ui/BufferContainer.tsx @@ -21,6 +21,7 @@ import { getParseArgs } from "../../../lib/helpers/parse-text-args"; import { formatUrl } from "../../../lib/helpers/url-formatter"; import { renderWeechatFormat } from "../../../lib/weechat/color-formatter"; import { StoreState } from "../../../store"; +import UndoTextInput from "./UndoTextInput"; interface Props { buffer: WeechatBuffer | null; @@ -72,6 +73,7 @@ class BufferContainer extends React.Component { showTabButton: false }); } + handleOnLongPress(type, text) { ActionSheetIOS.showShareActionSheetWithOptions( { @@ -82,6 +84,7 @@ class BufferContainer extends React.Component { () => null ); } + handleOnPress(type, text) { console.log(type, text); if (type === "channel") { @@ -178,7 +181,7 @@ class BufferContainer extends React.Component { parseArgs={this.parseArgs} /> - ; + +export default class UndoTextInput extends React.PureComponent { + constructor(props: Props) { + super(props) + this.value = props.value; + } + + textInput: TextInput; + value: string; + + componentDidUpdate() { + const { value } = this.props; + if (value !== this.value) { + this.textInput.setNativeProps({ text: value }) + this.value = value; + } + } + + handleChangeText = (textValue: string) => { + this.value = textValue; + this.props.onChangeText(textValue); + } + + render() { + const { value, onChangeText, ...rest } = this.props; + return ( + this.textInput = input} + onChangeText={this.handleChangeText} + /> + ); + } +} \ No newline at end of file