mirror of
https://github.com/pelgraine/Meck.git
synced 2026-08-10 10:42:42 +02:00
fiiiiixed the contacts add and delete and toggle fav issues for real this time
This commit is contained in:
@@ -315,6 +315,7 @@ bool MyMesh::isAutoAddEnabled() const {
|
||||
}
|
||||
|
||||
bool MyMesh::shouldAutoAddContactType(uint8_t contact_type) const {
|
||||
if (_forceNextImport) return true; // explicit user add from Last Heard / Discovery
|
||||
if ((_prefs.manual_add_contacts & 1) == 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -360,6 +361,7 @@ void MyMesh::onContactsFull() {
|
||||
}
|
||||
|
||||
void MyMesh::onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path_len, const uint8_t* path) {
|
||||
_forceNextImport = false; // clear force-add flag (set by forceImportContact)
|
||||
if (_serial->isConnected()) {
|
||||
if (is_new) {
|
||||
writeContactRespFrame(PUSH_CODE_NEW_ADVERT, contact);
|
||||
@@ -3259,6 +3261,13 @@ void MyMesh::stopDiscovery() {
|
||||
_discoveryActive = false;
|
||||
}
|
||||
|
||||
bool MyMesh::forceImportContact(const uint8_t* blob, uint8_t len) {
|
||||
_forceNextImport = true;
|
||||
bool ok = importContact(blob, len);
|
||||
if (!ok) _forceNextImport = false; // clear if importContact failed (no loopback queued)
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool MyMesh::addDiscoveredToContacts(int idx) {
|
||||
if (idx < 0 || idx >= _discoveredCount) return false;
|
||||
if (_discovered[idx].already_in_contacts) return true; // already there
|
||||
@@ -3267,7 +3276,7 @@ bool MyMesh::addDiscoveredToContacts(int idx) {
|
||||
uint8_t buf[256];
|
||||
int plen = getBlobByKey(_discovered[idx].contact.id.pub_key, PUB_KEY_SIZE, buf);
|
||||
if (plen > 0) {
|
||||
bool ok = importContact(buf, (uint8_t)plen);
|
||||
bool ok = forceImportContact(buf, (uint8_t)plen);
|
||||
if (ok) {
|
||||
_discovered[idx].already_in_contacts = true;
|
||||
dirty_contacts_expiry = futureMillis(LAZY_CONTACTS_WRITE_DELAY);
|
||||
|
||||
@@ -131,6 +131,9 @@ public:
|
||||
int getContactBlob(const uint8_t key[], int key_len, uint8_t dest_buf[]) {
|
||||
return getBlobByKey(key, key_len, dest_buf);
|
||||
}
|
||||
// Force-add a contact from a raw advert blob, bypassing auto-add settings.
|
||||
// Used by Last Heard and Discovery when the user explicitly selects a node to add.
|
||||
bool forceImportContact(const uint8_t* blob, uint8_t len);
|
||||
|
||||
// Queue a sent channel message for BLE app sync
|
||||
void queueSentChannelMessage(uint8_t channel_idx, uint32_t timestamp, const char* sender, const char* text);
|
||||
@@ -261,6 +264,7 @@ private:
|
||||
NodePrefs _prefs;
|
||||
VoiceRawHandler _voiceHandler = nullptr;
|
||||
VoiceEnvelopeHandler _voiceEnvHandler = nullptr;
|
||||
mutable bool _forceNextImport = false;
|
||||
bool _deferSaves = false;
|
||||
uint32_t pending_login;
|
||||
uint32_t pending_status;
|
||||
|
||||
@@ -1111,7 +1111,7 @@ static void lastHeardToggleContact() {
|
||||
uint8_t blob[256];
|
||||
int blobLen = the_mesh.getContactBlob(entry->pubkey_prefix, 8, blob);
|
||||
if (blobLen > 0) {
|
||||
the_mesh.importContact(blob, blobLen);
|
||||
the_mesh.forceImportContact(blob, blobLen);
|
||||
the_mesh.scheduleLazyContactSave();
|
||||
char alertBuf[40];
|
||||
snprintf(alertBuf, sizeof(alertBuf), "Added: %s", entry->name);
|
||||
|
||||
Reference in New Issue
Block a user