a better fix for the problem of sending messages while device is asleep

Better just to Observe myId and wait for it to be !null
This commit is contained in:
geeksville
2020-04-21 20:48:44 -07:00
parent 1558675cc7
commit 5abb56ec3f

View File

@@ -169,11 +169,18 @@ class MessagesFragment : ScreenFragment("Messages"), Logging {
messagesAdapter.onMessagesChanged(it)
})
// If connection state _OR_ myID changes we have to fix our ability to edit outgoing messages
model.isConnected.observe(viewLifecycleOwner, Observer { connected ->
// If we don't know our node ID and we are offline don't let user try to send
textInputLayout.isEnabled =
connected != MeshService.ConnectionState.DISCONNECTED && model.nodeDB.myId.value != null
})
model.nodeDB.myId.observe(viewLifecycleOwner, Observer { myId ->
// If we don't know our node ID and we are offline don't let user try to send
textInputLayout.isEnabled =
model.isConnected.value != MeshService.ConnectionState.DISCONNECTED && myId != null
})
}
private val dateFormat = SimpleDateFormat("h:mm a")