diff --git a/Configuration.cpp b/Configuration.cpp index 57978f907..3cc900e57 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -1004,13 +1004,11 @@ Configuration::impl::impl (Configuration * self, QNetworkAccessManager * network // this must be done after the default paths above are set read_settings (); - // conditionally load LotW users data - ui_->LotW_CSV_fetch_push_button->setEnabled (false); + // set up LoTW users CSV file fetching connect (&lotw_users_, &LotWUsers::load_finished, [this] () { ui_->LotW_CSV_fetch_push_button->setEnabled (true); }); lotw_users_.set_local_file_path (writeable_data_dir_.absoluteFilePath ("lotw-user-activity.csv")); - lotw_users_.load (ui_->LotW_CSV_URL_line_edit->text ()); // // validation diff --git a/LotWUsers.cpp b/LotWUsers.cpp index 3876cd7bf..877e70549 100644 --- a/LotWUsers.cpp +++ b/LotWUsers.cpp @@ -1,6 +1,7 @@ #include "LotWUsers.hpp" #include +#include #include #include @@ -265,7 +266,9 @@ void LotWUsers::set_age_constraint (qint64 uploaded_since_days) bool LotWUsers::user (QString const& call) const { - if (m_->future_load_.valid ()) + // check if a pending asynchronous load is ready + if (m_->future_load_.valid () + && std::future_status::ready == m_->future_load_.wait_for (std::chrono::seconds {0})) { try { @@ -278,10 +281,13 @@ bool LotWUsers::user (QString const& call) const } Q_EMIT load_finished (); } - auto p = m_->last_uploaded_.constFind (call); - if (p != m_->last_uploaded_.end ()) + if (m_->last_uploaded_.size ()) { - return p.value ().daysTo (QDate::currentDate ()) <= m_->age_constraint_; + auto p = m_->last_uploaded_.constFind (call); + if (p != m_->last_uploaded_.end ()) + { + return p.value ().daysTo (QDate::currentDate ()) <= m_->age_constraint_; + } } return false; } diff --git a/widgets/displaytext.cpp b/widgets/displaytext.cpp index 73df8af63..56e7931be 100644 --- a/widgets/displaytext.cpp +++ b/widgets/displaytext.cpp @@ -400,7 +400,11 @@ void DisplayText::displayDecodedText(DecodedText const& decodedText, QString con } else { - highlight_types types {Highlight::CQ, Highlight::LotW}; + highlight_types types {Highlight::CQ}; + if (m_config && m_config->lotw_users ().user (decodedText.CQersCall())) + { + types.push_back (Highlight::LotW); + } set_colours (m_config, &bg, &fg, types); } }