Implements quick connection fetch for non owned atoms
@@ -230,6 +230,11 @@ export function fetchAtomAndDispatch(
});
return atom;
})
+ .then(atom => {
+ //Fetch All MetaConnections Of NonOwnedPersonaAndDispatch //TODO: ENHANCE LOADING PROCESS BY LOADING CONNECTIONS ONLY ON POST VIEW
+ fetchConnectionsOfNonOwnedAtomAndDispatch(personaUri, dispatch);
+ return atom;
+ })
.catch(err => {
const errResponse = err && err.response;
const isDeleted = !!(errResponse && errResponse.status == 410);
@@ -254,6 +259,11 @@ export function fetchAtomAndDispatch(
});
return atom;
})
+ .then(atom => {
+ //Fetch All MetaConnections Of NonOwnedAtomAndDispatch //TODO: ENHANCE LOADING PROCESS BY LOADING CONNECTIONS ONLY ON POST VIEW
+ fetchConnectionsOfNonOwnedAtomAndDispatch(atomUri, dispatch);
+ return atom;
+ })
.catch(err => {
const errResponse = err && err.response;
const isDeleted = !!(errResponse && errResponse.status == 410);
@@ -450,6 +460,24 @@ export function fetchConnectionsOfAtomAndDispatch(atomUri, dispatch) {
);
}
+export function fetchConnectionsOfNonOwnedAtomAndDispatch(atomUri, dispatch) {
+ return won
+ .getConnectionUrisWithStateByAtomUri(atomUri, atomUri)
+ .then(connectionsWithStateAndSocket => {
+ const connectedConnections = connectionsWithStateAndSocket.filter(
+ conn => conn.connectionState === vocab.WON.Connected
+ );
+
+ dispatch({
+ type: actionTypes.connections.storeMetaConnections,
+ payload: Immutable.fromJS({
+ atomUri: atomUri,
+ connections: connectedConnections,
+ }),
+ });
+ });
+}
+
/**
* fetches Data for atomUri
* @param atomUri uri to be fetched
