mirror of
https://github.com/vicliu624/trail-mate.git
synced 2026-10-07 02:57:21 +00:00
fix(map): retain geocaches when map information is hidden
This commit is contained in:
@@ -404,6 +404,15 @@ target_link_libraries(geocaching_browse_runtime_test PRIVATE geocaching_native_h
|
||||
add_test(NAME geocaching_browse_runtime COMMAND geocaching_browse_runtime_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures)
|
||||
|
||||
add_executable(geocaching_local_map_test test_local_map_overlay.cpp)
|
||||
set(GPS_RUNTIME "${CMAKE_CURRENT_SOURCE_DIR}/../../ui_shared/src/ui/screens/gps/gps_page_runtime.cpp")
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${GPS_RUNTIME}")
|
||||
file(READ "${GPS_RUNTIME}" GPS_RUNTIME_SOURCE)
|
||||
string(FIND "${GPS_RUNTIME_SOURCE}" "void keep_only_current_position_overlay(" FILTER_START)
|
||||
string(SUBSTRING "${GPS_RUNTIME_SOURCE}" ${FILTER_START} -1 FILTER_TAIL)
|
||||
string(FIND "${FILTER_TAIL}" "bool load_map_track_file_impl(" FILTER_LENGTH)
|
||||
string(SUBSTRING "${FILTER_TAIL}" 0 ${FILTER_LENGTH} MAP_FILTER)
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/geocaching_map_filter.inc" "${MAP_FILTER}")
|
||||
target_include_directories(geocaching_local_map_test PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
target_include_directories(geocaching_local_map_test PRIVATE ../../ui_presentation/include)
|
||||
target_compile_features(geocaching_local_map_test PRIVATE cxx_std_17)
|
||||
if(MSVC)
|
||||
|
||||
@@ -498,6 +498,25 @@ int main(int argc, char** argv)
|
||||
// Cold offline startup has no dispatch destination or QueryClient yet.
|
||||
// Saved rows and full details must not wait for either to become available.
|
||||
router.ready = false;
|
||||
// Open the main map directly, without warming either Geocaching list.
|
||||
{
|
||||
test::source->activate(true);
|
||||
auto overlays = std::make_unique<ui::geocaching::LocalMapOverlay>();
|
||||
auto map = std::make_unique<ui::map::MapOverlaySnapshot>();
|
||||
for (unsigned frame = 0; frame < 100 && map->item_count != 2; ++frame)
|
||||
{
|
||||
overlays->update(*test::source, 31, 121, 15);
|
||||
*map = {};
|
||||
overlays->append(*map);
|
||||
for (unsigned work = 0; work < 150; ++work) tick();
|
||||
}
|
||||
require(map->item_count == 2 && map->header.valid, "direct main map did not load local markers");
|
||||
test::source->activate(false);
|
||||
tick();
|
||||
until([&]
|
||||
{ return std::strstr(snapshot(Section::Published).status.data(), "Starting Geocaching"); },
|
||||
"direct map session did not close");
|
||||
}
|
||||
const auto installed_gpx = std::find_if(disk.begin(), disk.end(), [](const auto& file)
|
||||
{ return file.first.find("/.state/") == std::string::npos && file.first.size() >= 4 && file.first.substr(file.first.size() - 4) == ".gpx"; });
|
||||
require(installed_gpx != disk.end(), "restart test requires an installed GPX");
|
||||
|
||||
@@ -5,6 +5,19 @@
|
||||
#include <vector>
|
||||
|
||||
using namespace ui::geocaching;
|
||||
namespace
|
||||
{
|
||||
enum class TrackOverlayFileKind
|
||||
{
|
||||
Track,
|
||||
Route
|
||||
};
|
||||
bool s_track_overlay_active = false;
|
||||
bool s_route_image_strip_visible = false;
|
||||
TrackOverlayFileKind s_track_overlay_kind = TrackOverlayFileKind::Track;
|
||||
// Compile the actual shared Map filter, rather than duplicating its rules.
|
||||
#include "geocaching_map_filter.inc"
|
||||
} // namespace
|
||||
struct LocalSource : Source
|
||||
{
|
||||
std::vector<Item> drafts, downloaded;
|
||||
@@ -68,6 +81,8 @@ int main()
|
||||
projection->append(*out);
|
||||
assert(out->item_count == 10); // Includes drafts beyond the first four rows.
|
||||
assert(out->header.valid); // Local markers render even without a GPS fix.
|
||||
keep_only_current_position_overlay(*out);
|
||||
assert(out->item_count == 10); // Hiding map chrome must retain saved places.
|
||||
assert(out->items[0].style == ui::map::MapOverlayStyle::Warning);
|
||||
assert(out->items[9].style == ui::map::MapOverlayStyle::Default);
|
||||
const auto requests = source.requests;
|
||||
|
||||
@@ -3025,6 +3025,9 @@ void keep_only_current_position_overlay(::ui::map::MapOverlaySnapshot& snapshot)
|
||||
const auto& item = snapshot.items[read];
|
||||
const bool keep_item =
|
||||
item.kind == ::ui::map::MapOverlayKind::CurrentPosition ||
|
||||
// Saved places remain visible like Agenda markers and POIs when
|
||||
// map chrome is hidden; this toggle only hides transient info.
|
||||
item.kind == ::ui::map::MapOverlayKind::Geocache ||
|
||||
(keep_route_points && item.kind == ::ui::map::MapOverlayKind::RoutePoint) ||
|
||||
(keep_selected_route_image &&
|
||||
item.kind == ::ui::map::MapOverlayKind::SelectedTarget);
|
||||
|
||||
Reference in New Issue
Block a user