Remove await in favor of promise chain
@@ -29,7 +29,7 @@ export function atomsConnectSockets(
targetSocketUri,
connectMessage
) {
- return async dispatch => {
+ return dispatch => {
if (!senderSocketUri) {
throw new Error("SenderSocketUri not present");
}
@@ -44,9 +44,8 @@ export function atomsConnectSockets(
targetSocketUri: targetSocketUri,
});
- const optimisticEvent = await won.wonMessageFromJsonLd(cnctMsg.message);
-
- return ownerApi.sendMessage(cnctMsg.message).then(jsonResp => {
+ return won.wonMessageFromJsonLd(cnctMsg.message).then(optimisticEvent =>
+ ownerApi.sendMessage(cnctMsg.message).then(jsonResp => {
dispatch({
type: actionTypes.atoms.connectSockets,
payload: {
@@ -57,7 +56,8 @@ export function atomsConnectSockets(
targetSocketUri: targetSocketUri,
},
});
- });
+ })
+ );
};
}
@@ -70,7 +70,7 @@ export function atomsConnect(
socketType,
targetSocketType
) {
- return async (dispatch, getState) => {
+ return (dispatch, getState) => {
const state = getState();
const ownedAtom = state.getIn(["atoms", ownedAtomUri]);
const theirAtom = state.getIn(["atoms", theirAtomUri]);
@@ -95,9 +95,8 @@ export function atomsConnect(
socketUri: socketUri,
targetSocketUri: targetSocketUri,
});
- const optimisticEvent = await won.wonMessageFromJsonLd(cnctMsg.message);
-
- return ownerApi.sendMessage(cnctMsg.message).then(jsonResp => {
+ return won.wonMessageFromJsonLd(cnctMsg.message).then(optimisticEvent =>
+ ownerApi.sendMessage(cnctMsg.message).then(jsonResp => {
dispatch({
type: actionTypes.atoms.connect,
payload: {
@@ -111,7 +110,8 @@ export function atomsConnect(
targetAtomUri: get(theirAtom, "uri"),
},
});
- });
+ })
+ );
};
}
