remove success flag from message handler

This commit is contained in:
Felicio Mununga 2022-06-17 14:02:40 +02:00
parent 6a027fb2bc
commit 7d720018f5
No known key found for this signature in database
GPG Key ID: 0EB8D75C775AB6F1
1 changed files with 2 additions and 20 deletions

View File

@ -66,7 +66,7 @@ export function handleWakuMessage(
return return
} }
let success = false client.wakuMessages.add(messageId)
// decode, map and handle (events) // decode, map and handle (events)
try { try {
@ -78,8 +78,6 @@ export function handleWakuMessage(
// handle (state and callback) // handle (state and callback)
community.handleDescription(decodedPayload) community.handleDescription(decodedPayload)
success = true
break break
} }
@ -99,8 +97,6 @@ export function handleWakuMessage(
// handle // handle
community.chats.get(chatUuid)?.handleNewMessage(chatMessage) community.chats.get(chatUuid)?.handleNewMessage(chatMessage)
success = true
break break
} }
@ -114,8 +110,6 @@ export function handleWakuMessage(
.get(chatUuid) .get(chatUuid)
?.handleEditedMessage(messageId, decodedPayload.text) ?.handleEditedMessage(messageId, decodedPayload.text)
success = true
break break
} }
@ -127,8 +121,6 @@ export function handleWakuMessage(
community.chats.get(chatUuid)?.handleDeletedMessage(messageId) community.chats.get(chatUuid)?.handleDeletedMessage(messageId)
success = true
break break
} }
@ -142,8 +134,6 @@ export function handleWakuMessage(
.get(chatUuid) .get(chatUuid)
?.handlePinnedMessage(messageId, decodedPayload.pinned) ?.handlePinnedMessage(messageId, decodedPayload.pinned)
success = true
break break
} }
@ -161,23 +151,15 @@ export function handleWakuMessage(
`0x${bytesToHex(publicKey)}` `0x${bytesToHex(publicKey)}`
) )
success = true
break break
} }
default: default:
success = true
break break
} }
} catch { } catch {
// protons-runtime throws when trying to decode invalid protocol buffers // protons-runtime throws when trying to decode invalid protocol buffers
success = true // eslint-disable-next-line no-empty
}
if (success) {
client.wakuMessages.add(messageId)
} }
return return