Avoid hint for inactive needs
Check the state of the need before sending hint.
issue
@@ -289,8 +289,10 @@ export function hintMessageReceived(event) {
//first check if we really have the 'own' need in the state - otherwise we'll ignore the hint
if (!getState().getIn(['needs', event.getReceiverNeed()])) {
console.log("ignoring hint for a need that is not ours:", event.getReceiverNeed());
- }
-
+ } else {
+ //check the state of the need and ignore hint if it is inactive
+ const needState = getState().getIn(['needs', event.getReceiverNeed(), 'state']);
+ if (needState == won.WON.ActiveCompacted) {
//event.eventType = won.messageType2EventType[event.hasMessageType]; TODO needed?
won.invalidateCacheForNewConnection(event.getReceiver(), event.getReceiverNeed())
.then(() => {
@@ -325,6 +327,10 @@ export function hintMessageReceived(event) {
console.log("handling hint message")
});
+ } else {
+ console.log("ignoring hint for a closed need:", event.getReceiverNeed());
+ }
+ }
}
}
