remove old method of deleting connecitons to your own needs (replaced with todo stub)
@@ -12,6 +12,11 @@ import eventReducer from './event-reducer';
import userReducer from './user-reducer';
import toastReducer from './toast-reducer';
import connectionReducer from './connection-reducer';
+import {
+ selectAllConnections,
+ selectNeedByConnectionUri,
+ selectAllOwnNeeds
+} from '../selectors';
/*
* this reducer attaches a 'router' object to our state that keeps the routing state.
@@ -131,7 +136,7 @@ export default reduceReducers( //passes on the state from one reducer to another
case actionTypes.login:
case actionTypes.messages.connectMessageReceived:
case actionTypes.messages.hintMessageReceived:
- return deleteCnctBetweenOwned(state);
+ return deleteConnectionsBetweenOwnNeeds(state);
/*
* TODO try to resolve a lot of the AC-dispatching so only
@@ -150,43 +155,10 @@ export default reduceReducers( //passes on the state from one reducer to another
window.ImmutableFoo = Immutable;
-function deleteCnctBetweenOwned(state) {
- var cnctBetweenOwned = selectCnctUrisBetweenOwnedNeeds(state);
- return cnctBetweenOwned.reduce(purgeConnection, state); //remove all those connections
-}
-
-function selectCnctUrisBetweenOwnedNeeds(state) {
-
- const ownedNeedsUris = state
- .getIn(['needs', 'ownNeeds'])
- .keySeq().toSet();
-
- const cnctBetweenOwned = state
- .get('connections')
- .filter(connection =>
- ownedNeedsUris.contains(
- connection.get('hasRemoteNeed')
- )
- );
-
- return cnctBetweenOwned.keySeq().toSet();
-}
+//TODO: DELETE CONNECTIONS BETWEEN OWNED
+function deleteConnectionsBetweenOwnNeeds(state) {
+ //TODO: REMOVE CONNECTION
+ //remove all connections (['needs','allNeeds', needUri, 'connections', connectionUri, 'remoteNeedUri']) that have a remoteNeedId that is also an ownNeed (['needs','allNeeds', needUri, 'ownNeed'] == true)
-function purgeConnection(state, cnctUri) {
- const cnct = state.getIn(['connections', cnctUri]);
- state = state.deleteIn(['connections', cnctUri]);
- cnct.get('hasEvents').forEach(eventUri => {
- state = state.deleteIn(['events', 'events', eventUri]);
- })
- const needUri = cnct.get('belongsToNeed');
-
- const path = [
- 'needs', 'ownNeeds', needUri,
- 'hasConnections'
- ];
-
- state = state.updateIn(path, connections =>
- connections && connections.delete(cnctUri)
- );
return state;
}
\ No newline at end of file
