chore: make variable used as boolean, a boolean

This commit is contained in:
fryorcraken.eth 2023-02-27 13:54:13 +11:00
parent ea6b5ab767
commit 6c37ee5f19
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 3 additions and 4 deletions

View File

@ -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);
}); });
} }