fix: use truthy value for emoji field on Reaction packets#4524
Conversation
Sets the `emoji` field in the `DataPacket` to a constant value of `1` for all reactions. This change modifies how reactions are sent, using a fixed indicator instead of the emoji's codepoint to signify a reaction packet. Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates reaction packet construction so the DataPacket.emoji field is always set to a fixed truthy value (1) for reactions, aligning reaction signaling with the app’s reaction-detection logic (decoded.reply_id != 0 && decoded.emoji != 0).
Changes:
- Set a constant
EMOJI_INDICATOR = 1for reaction packets sent from notification reactions (ReactionReceiver). - Set the same constant
EMOJI_INDICATOR = 1for reaction packets sent via service actions (MeshActionHandler). - Minor cleanup to use the imported
DataPackettype inMeshActionHandler.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| app/src/main/java/com/geeksville/mesh/service/ReactionReceiver.kt | Sends reaction DataPacket with emoji = 1 as a truthy reaction indicator. |
| app/src/main/java/com/geeksville/mesh/service/MeshActionHandler.kt | Sends reaction DataPacket with emoji = 1 for ServiceAction.Reaction. |
| const val EXTRA_CONTACT_KEY = "contactKey" | ||
| const val EXTRA_TO_ID = "toId" | ||
| const val EXTRA_CHANNEL_INDEX = "channelIndex" | ||
| private const val EMOJI_INDICATOR = 1 |
There was a problem hiding this comment.
EMOJI_INDICATOR is duplicated here and in MeshActionHandler. Consider defining a single shared constant (e.g., a top-level REACTION_EMOJI_INDICATOR in com.geeksville.mesh.service) so the reaction-flag value can’t drift across call sites, and document that it’s a non-zero flag (not the emoji codepoint).
|
|
||
| companion object { | ||
| private const val DEFAULT_REBOOT_DELAY = 5 | ||
| private const val EMOJI_INDICATOR = 1 |
There was a problem hiding this comment.
EMOJI_INDICATOR is also defined in ReactionReceiver; having two independent definitions increases the chance of divergence. Prefer reusing a single shared constant for the reaction emoji-flag, with a short comment explaining why the value is 1 (truthy indicator vs. codepoint).
| private const val EMOJI_INDICATOR = 1 | |
| // Reuse the shared emoji reaction flag; 1 means "has emoji reaction" (truthy), not a Unicode codepoint. | |
| private const val EMOJI_INDICATOR: Int = ReactionReceiver.EMOJI_INDICATOR |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4524 +/- ##
=======================================
Coverage 11.23% 11.23%
=======================================
Files 424 424
Lines 14432 14432
Branches 2397 2397
=======================================
Hits 1621 1621
+ Misses 12515 12514 -1
- Partials 296 297 +1 ☔ View full report in Codecov by Sentry. |
Sets the
emojifield in theDataPacketto a constant value of1for all reactions.This change modifies how reactions are sent, using a fixed indicator instead of the emoji's codepoint to signify a reaction packet.