Move adHocAtom Creation after the success-handlers have been dispatched, this is to avoid race conditions
@@ -520,17 +520,6 @@ function connectAdHoc(
}
}
- // create the new atom
- dispatch({
- type: actionTypes.atoms.create, // TODO custom action
- payload: {
- eventUri,
- message,
- atomUri,
- atom: adHocDraft,
- },
- });
-
// set default socketUri
let socketUri = `${atomUri}#chatSocket`;
@@ -582,6 +571,17 @@ function connectAdHoc(
actionToDispatch: connectAction,
},
});
+
+ // create the new atom
+ dispatch({
+ type: actionTypes.atoms.create, // TODO custom action
+ payload: {
+ eventUri,
+ message,
+ atomUri,
+ atom: adHocDraft,
+ },
+ });
});
});
}
