Fix racecondition
@@ -571,6 +571,7 @@ export function processConnectMessage(wonMessage) {
);
}
+ Promise.all([senderAtomP, recipientAtomP]).then(() => {
let senderCP;
if (!senderConnectionUri && isOwnSenderAtom) {
senderCP = stateStore
@@ -638,28 +639,22 @@ export function processConnectMessage(wonMessage) {
}
//we have to retrieve the personas too
- Promise.all([senderCP, receiverCP, senderAtomP, recipientAtomP]).then(
- ([
- senderConnectionRelevant,
- receiverConnectionRelevant,
- senderAtom,
- recipientAtom,
- ]) => {
+ Promise.all([senderCP, receiverCP]).then(
+ ([senderConnectionRelevant, receiverConnectionRelevant]) => {
const newState = getState();
if (receiverConnectionRelevant) {
- const newRecipientAtom = getIn(newState, ["atoms", recipientAtomUri]);
+ const newRecipientAtom = getIn(newState, [
+ "atoms",
+ recipientAtomUri,
+ ]);
const newReceiverConnection = atomUtils.getConnectionBySocketUris(
newRecipientAtom,
targetSocketUri,
senderSocketUri
);
- console.debug(
- "Change ReceiverConnectionState ",
- newRecipientAtom,
- recipientAtom
- );
+ console.debug("Change ReceiverConnectionState ", newRecipientAtom);
dispatch({
type: actionTypes.messages.connectMessageReceived,
payload: {
@@ -678,11 +673,7 @@ export function processConnectMessage(wonMessage) {
targetSocketUri
);
- console.debug(
- "Change SenderConnectionState ",
- newSenderAtom,
- senderAtom
- );
+ console.debug("Change SenderConnectionState ", newSenderAtom);
dispatch({
type: actionTypes.messages.connectMessageSent,
payload: {
@@ -694,6 +685,7 @@ export function processConnectMessage(wonMessage) {
}
}
);
+ });
};
}
