mirror of https://github.com/waku-org/js-waku.git
chore: make variable used as boolean, a boolean
This commit is contained in:
parent
ea6b5ab767
commit
6c37ee5f19
|
@ -6,7 +6,6 @@ import type {
|
||||||
IDecodedMessage,
|
IDecodedMessage,
|
||||||
IDecoder,
|
IDecoder,
|
||||||
IFilter,
|
IFilter,
|
||||||
IMessage,
|
|
||||||
ProtocolCreateOptions,
|
ProtocolCreateOptions,
|
||||||
ProtocolOptions,
|
ProtocolOptions,
|
||||||
} from "@waku/interfaces";
|
} from "@waku/interfaces";
|
||||||
|
@ -165,12 +164,12 @@ class Filter extends BaseProtocol implements IFilter {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let msg: IMessage | undefined;
|
let didDecodeMsg = false;
|
||||||
// We don't want to wait for decoding failure, just attempt to decode
|
// We don't want to wait for decoding failure, just attempt to decode
|
||||||
// all messages and do the call back on the one that works
|
// all messages and do the call back on the one that works
|
||||||
// noinspection ES6MissingAwait
|
// noinspection ES6MissingAwait
|
||||||
decoders.forEach(async (dec) => {
|
decoders.forEach(async (dec) => {
|
||||||
if (msg) return;
|
if (didDecodeMsg) return;
|
||||||
const decoded = await dec.fromProtoObj(toProtoMessage(protoMessage));
|
const decoded = await dec.fromProtoObj(toProtoMessage(protoMessage));
|
||||||
if (!decoded) {
|
if (!decoded) {
|
||||||
log("Not able to decode message");
|
log("Not able to decode message");
|
||||||
|
@ -178,7 +177,7 @@ class Filter extends BaseProtocol implements IFilter {
|
||||||
}
|
}
|
||||||
// This is just to prevent more decoding attempt
|
// This is just to prevent more decoding attempt
|
||||||
// TODO: Could be better if we were to abort promises
|
// TODO: Could be better if we were to abort promises
|
||||||
msg = decoded;
|
didDecodeMsg = Boolean(decoded);
|
||||||
await callback(decoded);
|
await callback(decoded);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue