mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-05-19 14:15:02 -04:00
[CP-1210] Contacts imported from SIM dont show up in Mudita Center
Fix for imported contacts from SIM don't show up in Mudita Center. Added functionality to send notification after all imported contacts are added to the database.
This commit is contained in:
committed by
Łukasz Mastalerz
parent
942b837f92
commit
d7c8a8a6bf
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
|
||||
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
|
||||
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
||||
|
||||
#include "SimContactsRepository.hpp"
|
||||
@@ -93,11 +93,15 @@ void SimContactsRepository::save(const std::vector<bool> &selectedContacts,
|
||||
if (result == nullptr) {
|
||||
return false;
|
||||
}
|
||||
for (const auto &r : result->getResult()) {
|
||||
sendNotification(r);
|
||||
}
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
task->execute(application, this);
|
||||
}
|
||||
|
||||
@@ -141,6 +145,13 @@ void SimContactsRepository::updateImportedRecords(const std::vector<cellular::Si
|
||||
#endif
|
||||
}
|
||||
|
||||
void SimContactsRepository::sendNotification(const NotificationData ¬ificationData)
|
||||
{
|
||||
auto notificationMessage = std::make_shared<db::NotificationMessage>(
|
||||
db::Interface::Name::Contact, notificationData.first, notificationData.second);
|
||||
application->bus.sendMulticast(notificationMessage, sys::BusChannel::ServiceDBNotifications);
|
||||
}
|
||||
|
||||
#if DEBUG_SIM_IMPORT_DATA == 1
|
||||
void SimContactsRepository::printRecordsData(const std::string &name, const std::vector<ContactRecord> &data)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
|
||||
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
|
||||
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
||||
|
||||
#pragma once
|
||||
@@ -27,6 +27,7 @@ class AbstractSimContactsRepository
|
||||
class SimContactsRepository : public AbstractSimContactsRepository, public app::AsyncCallbackReceiver
|
||||
{
|
||||
public:
|
||||
using NotificationData = std::pair<db::Query::Type, uint32_t>;
|
||||
explicit SimContactsRepository(app::ApplicationCommon *application);
|
||||
|
||||
const std::vector<ContactRecord> &getImportedRecords() override;
|
||||
@@ -37,6 +38,9 @@ class SimContactsRepository : public AbstractSimContactsRepository, public app::
|
||||
void findDuplicates(const std::vector<bool> &selectedContacts, OnDupplicatesCheckCallback callback) override;
|
||||
void updateImportedRecords(const std::vector<cellular::SimContact> &simData);
|
||||
|
||||
protected:
|
||||
void sendNotification(const NotificationData ¬ificationData);
|
||||
|
||||
private:
|
||||
std::vector<ContactRecord> importedRecords;
|
||||
std::vector<ContactRecord> uniqueRecords;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
|
||||
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
|
||||
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
||||
|
||||
#include "AsyncTask.hpp"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
|
||||
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
|
||||
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
||||
|
||||
#include "ContactRecord.hpp"
|
||||
@@ -1471,8 +1471,10 @@ auto ContactRecordInterface::GetNumbersIdsByContact(std::uint32_t contactId) ->
|
||||
return numbersIds;
|
||||
}
|
||||
|
||||
auto ContactRecordInterface::MergeContactsList(std::vector<ContactRecord> &contacts) -> bool
|
||||
auto ContactRecordInterface::MergeContactsList(std::vector<ContactRecord> &contacts)
|
||||
-> std::vector<std::pair<db::Query::Type, uint32_t>>
|
||||
{
|
||||
std::vector<std::pair<db::Query::Type, uint32_t>> dataForNotification{};
|
||||
auto numberMatcher = buildNumberMatcher(NumberMatcherPageSize);
|
||||
|
||||
for (auto &contact : contacts) {
|
||||
@@ -1485,18 +1487,23 @@ auto ContactRecordInterface::MergeContactsList(std::vector<ContactRecord> &conta
|
||||
if (!matchedNumber.has_value()) {
|
||||
if (!Add(contact)) {
|
||||
LOG_ERROR("Contacts list merge fail when adding the contact.");
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
dataForNotification.push_back({db::Query::Type::Create, contactDB->getLastInsertRowId()});
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Complete override of the contact data
|
||||
contact.ID = matchedNumber->getContactID();
|
||||
dataForNotification.push_back({db::Query::Type::Update, contact.ID});
|
||||
|
||||
Update(contact);
|
||||
// Rebuild number matcher
|
||||
numberMatcher = buildNumberMatcher(NumberMatcherPageSize);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
return dataForNotification;
|
||||
}
|
||||
|
||||
auto ContactRecordInterface::CheckContactsListDuplicates(std::vector<ContactRecord> &contacts)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
|
||||
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
|
||||
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
||||
|
||||
#pragma once
|
||||
@@ -227,7 +227,7 @@ class ContactRecordInterface : public RecordInterface<ContactRecord, ContactReco
|
||||
* @param contacts vector of contacts with single number
|
||||
* @return boolean status
|
||||
*/
|
||||
auto MergeContactsList(std::vector<ContactRecord> &contacts) -> bool;
|
||||
auto MergeContactsList(std::vector<ContactRecord> &contacts) -> std::vector<std::pair<db::Query::Type, uint32_t>>;
|
||||
|
||||
/**
|
||||
* @brief Check which contacts in vector are duplicating contacts in DB
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
|
||||
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
|
||||
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
||||
|
||||
#include "QueryMergeContactsList.hpp"
|
||||
@@ -15,9 +15,15 @@ std::vector<ContactRecord> &MergeContactsList::getContactsList()
|
||||
return contacts;
|
||||
}
|
||||
|
||||
MergeContactsListResult::MergeContactsListResult(bool result) : result(result)
|
||||
MergeContactsListResult::MergeContactsListResult(const std::vector<std::pair<db::Query::Type, uint32_t>> &addedContacts)
|
||||
: addedContacts(addedContacts)
|
||||
{}
|
||||
|
||||
std::vector<std::pair<db::Query::Type, uint32_t>> &MergeContactsListResult::getResult()
|
||||
{
|
||||
return addedContacts;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto MergeContactsList::debugInfo() const -> std::string
|
||||
{
|
||||
return "MergeContactsList";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
|
||||
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
|
||||
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
||||
|
||||
#pragma once
|
||||
@@ -28,15 +28,12 @@ namespace db::query
|
||||
class MergeContactsListResult : public QueryResult
|
||||
{
|
||||
public:
|
||||
MergeContactsListResult(bool result);
|
||||
[[nodiscard]] auto getResult() const noexcept -> bool
|
||||
{
|
||||
return result;
|
||||
}
|
||||
MergeContactsListResult(const std::vector<std::pair<db::Query::Type, uint32_t>> &addedContacts);
|
||||
std::vector<std::pair<db::Query::Type, uint32_t>> &getResult();
|
||||
[[nodiscard]] auto debugInfo() const -> std::string override;
|
||||
|
||||
private:
|
||||
bool result = false;
|
||||
std::vector<std::pair<db::Query::Type, uint32_t>> addedContacts{};
|
||||
};
|
||||
|
||||
}; // namespace db::query
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
|
||||
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
|
||||
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
||||
|
||||
#include "common.hpp"
|
||||
@@ -523,7 +523,7 @@ TEST_CASE("Contacts list merge")
|
||||
std::vector<ContactRecord::Number>({ContactRecord::Number(rawContact.first, std::string(""))});
|
||||
contacts.push_back(record);
|
||||
}
|
||||
REQUIRE(records.MergeContactsList(contacts));
|
||||
REQUIRE(!records.MergeContactsList(contacts).empty());
|
||||
|
||||
// Validate if non-overlapping were appended to DB
|
||||
REQUIRE(records.GetCount() == (rawContactsInitial.size() + rawContactsToAdd.size()));
|
||||
@@ -565,7 +565,7 @@ TEST_CASE("Contacts list merge")
|
||||
std::vector<ContactRecord::Number>({ContactRecord::Number(rawContact.first, std::string(""))});
|
||||
contacts.push_back(record);
|
||||
}
|
||||
REQUIRE(records.MergeContactsList(contacts));
|
||||
REQUIRE(!records.MergeContactsList(contacts).empty());
|
||||
|
||||
REQUIRE(records.GetCount() == (rawContactsInitial.size() + numberOfNewContacts));
|
||||
|
||||
@@ -612,7 +612,7 @@ TEST_CASE("Contacts list merge - advanced cases")
|
||||
record.primaryName = rawContact.second;
|
||||
record.numbers = std::vector<ContactRecord::Number>({ContactRecord::Number(rawContact.first, std::string(""))});
|
||||
contacts.push_back(record);
|
||||
REQUIRE(records.MergeContactsList(contacts));
|
||||
REQUIRE(!records.MergeContactsList(contacts).empty());
|
||||
|
||||
REQUIRE(records.GetCount() == 1);
|
||||
|
||||
|
||||
@@ -45,6 +45,9 @@
|
||||
* Fixed broken French translation on 'Configure passcode' screen in Onboarding
|
||||
* Fixed time disappearing in SMS thread
|
||||
* Fixed scrollbar behavior in call log view
|
||||
* Fixed contacts imported from SIM do not show up in Mudita Center
|
||||
|
||||
### Added
|
||||
|
||||
## [1.5.0 2022-12-20]
|
||||
|
||||
|
||||
Submodule tools/misc updated: eeae49f9d8...82dce5ad55
Reference in New Issue
Block a user