Page MenuHomePhabricator

D4463.diff
No OneTemporary

D4463.diff

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<SendMessageResult>,
+newThread: (request: ClientNewThreadRequest) => Promise<NewThreadResult>,
+pushModal: (modal: React.Node) => void,
+ +sendCallbacks: $ReadOnlyArray<() => mixed>,
+ +registerSendCallback: (() => mixed) => void,
+ +unregisterSendCallback: (() => mixed) => 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,21 @@
const dispatchActionPromise = useDispatchActionPromise();
const modalContext = useModalContext();
+ const [sendCallbacks, setSendCallbacks] = React.useState<
+ $ReadOnlyArray<() => mixed>,
+ >([]);
+ const registerSendCallback = React.useCallback((callback: () => mixed) => {
+ setSendCallbacks(prevCallbacks => [...prevCallbacks, callback]);
+ }, []);
+ const unregisterSendCallback = React.useCallback(
+ (callback: () => mixed) => {
+ setSendCallbacks(prevCallbacks =>
+ prevCallbacks.filter(candidate => candidate !== callback),
+ );
+ },
+ [],
+ );
+
return (
<InputStateContainer
{...props}
@@ -1265,6 +1287,9 @@
dispatch={dispatch}
dispatchActionPromise={dispatchActionPromise}
pushModal={modalContext.pushModal}
+ sendCallbacks={sendCallbacks}
+ registerSendCallback={registerSendCallback}
+ unregisterSendCallback={unregisterSendCallback}
/>
);
},
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: (() => mixed) => void,
+ unregisterSendCallback: (() => mixed) => void,
};
const InputStateContext: React.Context<?InputState> = React.createContext<?InputState>(

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 2:28 PM (21 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2585113
Default Alt Text
D4463.diff (2 KB)

Event Timeline