diff --git a/web/input/input-state-container.react.js b/web/input/input-state-container.react.js --- a/web/input/input-state-container.react.js +++ b/web/input/input-state-container.react.js @@ -109,6 +109,9 @@ ) => Promise, +newThread: (request: ClientNewThreadRequest) => Promise, +pushModal: (modal: React.Node) => void, + +sendCallbacks: $ReadOnlyArray<() => void>, + +registerSendCallback: (() => void) => void, + +unregisterSendCallback: (() => void) => void, }; type State = { +pendingUploads: { @@ -498,6 +501,8 @@ addReply: (message: string) => this.addReply(message), addReplyListener: this.addReplyListener, removeReplyListener: this.removeReplyListener, + registerSendCallback: this.props.registerSendCallback, + unregisterSendCallback: this.props.unregisterSendCallback, }; }, ), @@ -937,6 +942,8 @@ messageInfo: RawTextMessageInfo, threadInfo: ThreadInfo, ) { + this.props.sendCallbacks.forEach(callback => callback()); + if (!threadIsPending(threadInfo.id)) { this.props.dispatchActionPromise( sendTextMessageActionTypes, @@ -1248,6 +1255,18 @@ const dispatchActionPromise = useDispatchActionPromise(); const modalContext = useModalContext(); + const [sendCallbacks, setSendCallbacks] = React.useState< + $ReadOnlyArray<() => void>, + >([]); + const registerSendCallback = (callback: () => void) => { + setSendCallbacks(prevCallbacks => [...prevCallbacks, callback]); + }; + const unregisterSendCallback = (callback: () => void) => { + setSendCallbacks(prevCallbacks => + prevCallbacks.filter(candidate => candidate !== callback), + ); + }; + return ( ); }, diff --git a/web/input/input-state.js b/web/input/input-state.js --- a/web/input/input-state.js +++ b/web/input/input-state.js @@ -57,6 +57,8 @@ addReply: (text: string) => void, addReplyListener: ((message: string) => void) => void, removeReplyListener: ((message: string) => void) => void, + registerSendCallback: (() => void) => void, + unregisterSendCallback: (() => void) => void, }; const InputStateContext: React.Context = React.createContext(