From aa88b344bc2470b46926015a05a4a8b6d5ac3168 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 36f786ca0..17dbdd6f7 100644 --- a/packages/mephisto-task/src/RemoteTask.js +++ b/packages/mephisto-task/src/RemoteTask.js @@ -29,6 +29,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 @@ -70,9 +71,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 = { @@ -85,6 +86,7 @@ const useMephistoRemoteProcedureTask = function (props) { if (agentId) { console.log("connecting..."); connect(agentId); + setConnectedAgentId(agentId); } }, [agentId]); @@ -133,6 +135,7 @@ const useMephistoRemoteProcedureTask = function (props) { return { ...otherMephistoProps, + agentId: connectedAgentId, // only show connected agent Ids remoteProcedure, disconnectIssueText, _fullSocketProps,