From 12b3bdafc263770394efc96bec22c82775d1bd67 Mon Sep 17 00:00:00 2001 From: Jack Urbanek Date: Wed, 27 Apr 2022 07:52:21 -0700 Subject: [PATCH] Fixing agent desync on RemoteProcedure tasks --- packages/mephisto-task/src/RemoteTask.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/mephisto-task/src/RemoteTask.js b/packages/mephisto-task/src/RemoteTask.js index 20add2570..3d74c19c1 100644 --- a/packages/mephisto-task/src/RemoteTask.js +++ b/packages/mephisto-task/src/RemoteTask.js @@ -27,6 +27,7 @@ const useMephistoRemoteProcedureTask = function (props) { // mapping of request ID to the callback object const requestCallbacks = {}; const [disconnectIssueText, setDisconnectIssueText] = React.useState(); + const [connectedAgentId, setConnectedAgentId] = React.useState(); // We register a ref so that the liveUpdate handler has access // to the current set of callbacks @@ -68,9 +69,9 @@ const useMephistoRemoteProcedureTask = function (props) { connect, destroy, sendLiveUpdate, + agentId, ...otherMephistoProps } = mephistoProps; - let { agentId } = mephistoProps; // They're still exposed in a separate manner though const _fullSocketProps = { @@ -83,6 +84,7 @@ const useMephistoRemoteProcedureTask = function (props) { if (agentId) { console.log("connecting..."); connect(agentId); + setConnectedAgentId(agentId); } }, [agentId]); @@ -131,6 +133,7 @@ const useMephistoRemoteProcedureTask = function (props) { return { ...otherMephistoProps, + agentId: connectedAgentId, // only show connected agent Ids remoteProcedure, disconnectIssueText, _fullSocketProps,