mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-08 19:07:26 +00:00
Last second fixes (#7156)
* Ditch the 30 second delay for button presses * Only order strictly weakly * Too many comments! * Only sort the populated meshNodes
This commit is contained in:
@@ -1694,23 +1694,22 @@ void NodeDB::sortMeshDB()
|
||||
{
|
||||
if (!Throttle::isWithinTimespanMs(lastSort, 1000 * 5)) {
|
||||
lastSort = millis();
|
||||
std::sort(meshNodes->begin(), meshNodes->end(), [](const meshtastic_NodeInfoLite &a, const meshtastic_NodeInfoLite &b) {
|
||||
if (a.num == myNodeInfo.my_node_num) {
|
||||
return true;
|
||||
}
|
||||
if (b.num == myNodeInfo.my_node_num) {
|
||||
return false;
|
||||
}
|
||||
bool aFav = a.is_favorite;
|
||||
bool bFav = b.is_favorite;
|
||||
if (aFav != bFav)
|
||||
return aFav;
|
||||
if (a.last_heard == 0 || a.last_heard == UINT32_MAX)
|
||||
return false;
|
||||
if (b.last_heard == 0 || b.last_heard == UINT32_MAX)
|
||||
return true;
|
||||
return a.last_heard > b.last_heard;
|
||||
});
|
||||
std::sort(meshNodes->begin(), meshNodes->begin() + numMeshNodes,
|
||||
[](const meshtastic_NodeInfoLite &a, const meshtastic_NodeInfoLite &b) {
|
||||
if (a.num == myNodeInfo.my_node_num) {
|
||||
return true;
|
||||
}
|
||||
if (b.num == myNodeInfo.my_node_num) {
|
||||
return false;
|
||||
}
|
||||
bool aFav = a.is_favorite;
|
||||
bool bFav = b.is_favorite;
|
||||
if (aFav != bFav)
|
||||
return aFav;
|
||||
if (a.last_heard != b.last_heard)
|
||||
return a.last_heard > b.last_heard;
|
||||
return a.num > b.num;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user