[booking] store key of unavailability reason instead of localized string.

This commit is contained in:
Arsentiy Milchakov 2020-08-04 16:37:17 +03:00 committed by Anatoliy V. Tomilov
parent d0984bf97f
commit 78ac08e3d1
4 changed files with 10 additions and 15 deletions

View file

@ -62,10 +62,9 @@ void SetUnavailable(search::Results const & filteredOut, SearchMarks & searchMar
if (filteredOut.GetCount() == 0)
return;
std::string reason = platform::GetLocalizedString("booking_map_component_availability");
for (auto const & filtered : filteredOut)
{
searchMarks.SetUnavailable(filtered.GetFeatureID(), reason);
searchMarks.SetUnavailable(filtered.GetFeatureID(), "booking_map_component_availability");
}
}
@ -74,10 +73,9 @@ void SetUnavailable(std::vector<FeatureID> const & filteredOut, SearchMarks & se
if (filteredOut.empty())
return;
std::string reason = platform::GetLocalizedString("booking_map_component_availability");
for (auto const & filtered : filteredOut)
{
searchMarks.SetUnavailable(filtered, reason);
searchMarks.SetUnavailable(filtered, "booking_map_component_availability");
}
}
} // namespace

View file

@ -1811,7 +1811,6 @@ void Framework::FillSearchResultsMarks(search::Results::ConstIter begin,
editSession.ClearGroup(UserMark::Type::SEARCH);
editSession.SetIsVisible(UserMark::Type::SEARCH, true);
optional<string> reason;
for (auto it = begin; it != end; ++it)
{
auto const & r = *it;
@ -1829,10 +1828,7 @@ void Framework::FillSearchResultsMarks(search::Results::ConstIter begin,
{
mark->SetPreparing(true);
if (!reason)
reason = platform::GetLocalizedString("booking_map_component_filters");
m_searchMarks.SetUnavailable(mark->GetFeatureID(), *reason);
m_searchMarks.SetUnavailable(mark->GetFeatureID(), "booking_map_component_filters");
}
if (r.m_details.m_isSponsoredHotel)
@ -3947,8 +3943,7 @@ void Framework::ShowViewportSearchResults(search::Results const & results, bool
auto const fillCallback = [this, clear, results](CachedResults filtersResults)
{
string const reason = platform::GetLocalizedString("booking_map_component_availability");
auto const postProcessing = [this, filtersResults = move(filtersResults), &reason](SearchMarkPoint & mark)
auto const postProcessing = [this, filtersResults = move(filtersResults)](SearchMarkPoint & mark)
{
auto const & id = mark.GetFeatureID();
@ -3991,7 +3986,7 @@ void Framework::ShowViewportSearchResults(search::Results const & results, bool
auto const isFilteredOut = binary_search(filteredOut.cbegin(), filteredOut.cend(), id);
if (isFilteredOut)
m_searchMarks.SetUnavailable(mark.GetFeatureID(), reason);
m_searchMarks.SetUnavailable(mark.GetFeatureID(), "booking_map_component_availability");
}
break;

View file

@ -8,6 +8,7 @@
#include "indexer/scales.hpp"
#include "platform/localization.hpp"
#include "platform/platform.hpp"
#include "base/stl_helpers.hpp"
@ -714,7 +715,7 @@ void SearchMarks::OnActivate(FeatureID const & featureId)
if (unavailableIt != m_unavailable.cend())
{
mark->SetAvailable(false);
mark->SetReason(unavailableIt->second);
mark->SetReason(platform::GetLocalizedString(unavailableIt->second));
}
});
}
@ -744,9 +745,9 @@ void SearchMarks::ClearVisited()
m_visited.clear();
}
void SearchMarks::SetUnavailable(FeatureID const & id, std::string const & reason)
void SearchMarks::SetUnavailable(FeatureID const & id, std::string const & reasonKey)
{
m_unavailable[id] = reason;
m_unavailable[id] = reasonKey;
}
bool SearchMarks::IsUnavailable(FeatureID const & id) const

View file

@ -137,5 +137,6 @@ private:
static std::map<std::string, m2::PointF> m_searchMarksSizes;
std::set<FeatureID> m_visited;
// The value is localized string key for unavailability reason.
std::map<FeatureID, std::string> m_unavailable;
};