mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-20 16:56:17 +00:00
Use isWithinTimespanMs to avoid refererence to NodeDb instance inside of NodeDb (#5453)
This commit is contained in:
parent
46eb534d76
commit
32f81568aa
@ -1275,10 +1275,14 @@ bool NodeDB::updateUser(uint32_t nodeId, meshtastic_User &p, uint8_t channelInde
|
|||||||
powerFSM.trigger(EVENT_NODEDB_UPDATED);
|
powerFSM.trigger(EVENT_NODEDB_UPDATED);
|
||||||
notifyObservers(true); // Force an update whether or not our node counts have changed
|
notifyObservers(true); // Force an update whether or not our node counts have changed
|
||||||
|
|
||||||
// We just changed something about the user, store our DB
|
// We just changed something about a User,
|
||||||
Throttle::execute(
|
// store our DB unless we just did so less than a minute ago
|
||||||
&lastNodeDbSave, ONE_MINUTE_MS, []() { nodeDB->saveToDisk(SEGMENT_DEVICESTATE); },
|
if (!Throttle::isWithinTimespanMs(lastNodeDbSave, ONE_MINUTE_MS)) {
|
||||||
[]() { LOG_DEBUG("Defer NodeDB saveToDisk for now"); }); // since we saved less than a minute ago
|
saveToDisk(SEGMENT_DEVICESTATE);
|
||||||
|
lastNodeDbSave = millis();
|
||||||
|
} else {
|
||||||
|
LOG_DEBUG("Defer NodeDB saveToDisk for now");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
|
Loading…
Reference in New Issue
Block a user