feat: add ActionMenu option to mute contacts (#1003)

This commit is contained in:
Andre K 2024-04-28 16:18:16 -03:00 committed by GitHub
parent b409c17fe8
commit ecaf35d7f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 626 additions and 25 deletions

View file

@ -574,7 +574,7 @@ class MeshService : Service(), Logging {
Portnums.PortNum.WAYPOINT_APP_VALUE,
)
private fun rememberDataPacket(dataPacket: DataPacket) {
private fun rememberDataPacket(dataPacket: DataPacket, updateNotification: Boolean = true) {
if (dataPacket.dataType !in rememberDataType) return
val fromLocal = dataPacket.from == DataPacket.ID_LOCAL
val toBroadcast = dataPacket.to == DataPacket.ID_BROADCAST
@ -590,7 +590,13 @@ class MeshService : Service(), Logging {
System.currentTimeMillis(),
dataPacket
)
insertPacket(packetToSave)
serviceScope.handledLaunch {
packetRepository.get().apply {
insert(packetToSave)
val isMuted = getContactSettings(contactKey).isMuted
if (updateNotification && !isMuted) updateMessageNotification(dataPacket)
}
}
}
/// Update our model and resend as needed for a MeshPacket we just received from the radio
@ -625,15 +631,13 @@ class MeshService : Service(), Logging {
debug("Received CLEAR_TEXT from $fromId")
rememberDataPacket(dataPacket)
updateMessageNotification(dataPacket)
}
Portnums.PortNum.WAYPOINT_APP_VALUE -> {
val u = MeshProtos.Waypoint.parseFrom(data.payload)
// Validate locked Waypoints from the original sender
if (u.lockedTo != 0 && u.lockedTo != packet.from) return
rememberDataPacket(dataPacket)
if (u.expire > currentSecond()) updateMessageNotification(dataPacket)
rememberDataPacket(dataPacket, u.expire > currentSecond())
}
// Handle new style position info
@ -694,13 +698,11 @@ class MeshService : Service(), Logging {
if (!moduleConfig.rangeTest.enabled) return
val u = dataPacket.copy(dataType = Portnums.PortNum.TEXT_MESSAGE_APP_VALUE)
rememberDataPacket(u)
updateMessageNotification(u)
}
Portnums.PortNum.DETECTION_SENSOR_APP_VALUE -> {
val u = dataPacket.copy(dataType = Portnums.PortNum.TEXT_MESSAGE_APP_VALUE)
rememberDataPacket(u)
updateMessageNotification(u)
}
Portnums.PortNum.TRACEROUTE_APP_VALUE -> {
@ -849,7 +851,6 @@ class MeshService : Service(), Logging {
dataType = Portnums.PortNum.TEXT_MESSAGE_APP_VALUE,
)
rememberDataPacket(u)
updateMessageNotification(u)
}
else -> {}
@ -1030,12 +1031,6 @@ class MeshService : Service(), Logging {
}
}
private fun insertPacket(packet: Packet) {
serviceScope.handledLaunch {
packetRepository.get().insert(packet)
}
}
private fun insertMeshLog(packetToSave: MeshLog) {
serviceScope.handledLaunch {
// Do not log, because might contain PII