Skip to content

Refactor map screen#203

Merged
wel97459 merged 1 commit into
mainfrom
dev-mapFilters
Feb 21, 2026
Merged

Refactor map screen#203
wel97459 merged 1 commit into
mainfrom
dev-mapFilters

Conversation

@wel97459

Copy link
Copy Markdown
Collaborator

Refactor map screen legend to add filtering so count of markers shown is right.
In path tracing mode it so only shows markers for repeaters and rooms.

Copilot AI review requested due to automatic review settings February 21, 2026 05:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors the map screen legend to properly count and display only the markers that are actually shown on the map. The main change involves modifying the _buildLegend method to calculate the node count by filtering contacts rather than accepting a pre-calculated count. Additionally, the marker filtering logic in _buildMarkers is updated to show only repeaters and rooms during path tracing mode.

Changes:

  • Modified _buildLegend signature to accept List<Contact> and settings instead of a pre-calculated node count, enabling accurate counting based on filter settings
  • Updated filter logic in _buildMarkers to conditionally apply filters based on path trace mode
  • Added duplicate filter logic in _buildLegend to count nodes consistently with what's displayed

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Widget _buildLegend(int nodeCount, int markerCount) {
Widget _buildLegend(
List<Contact> contactsWithLocation,
settings,

Copilot AI Feb 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The settings parameter is missing a type annotation. It should be explicitly typed as AppSettings for better type safety and code clarity. This is consistent with the convention used elsewhere in the codebase where the settings object is obtained from settingsService.settings which returns an AppSettings instance (see line 119).

Copilot uses AI. Check for mistakes.
);
}

List<Marker> _buildMarkers(List<Contact> contacts, settings) {

Copilot AI Feb 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The settings parameter is missing a type annotation. It should be explicitly typed as AppSettings for better type safety and code clarity. This is consistent with the convention used elsewhere in the codebase where the settings object is obtained from settingsService.settings which returns an AppSettings instance (see line 119).

Copilot uses AI. Check for mistakes.
Comment on lines 463 to 467
if (contact.type != advTypeChat &&
contact.type != advTypeRepeater &&
!settings.mapShowOtherNodes) {
(!settings.mapShowOtherNodes && !_isBuildingPathTrace)) {
continue;
}

Copilot AI Feb 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the PR description, path tracing mode should only show repeaters and rooms. However, this filter logic will show ALL "other" node types (including sensors) in path trace mode, not just rooms. The condition should specifically check for advTypeRoom when in path trace mode, or explicitly exclude advTypeSensor. Consider changing the logic to handle rooms separately: if in path trace mode, only allow repeaters (advTypeRepeater) and rooms (advTypeRoom) to pass through, while excluding chat nodes and sensors.

Copilot uses AI. Check for mistakes.
Comment on lines +542 to +560
Widget _buildLegend(
List<Contact> contactsWithLocation,
settings,
int markerCount,
) {
int nodeCount = 0;
for (final contact in contactsWithLocation) {
// Apply node type filters
if (contact.type == advTypeRepeater && !settings.mapShowRepeaters) {
continue;
}
if (contact.type == advTypeChat && !settings.mapShowChatNodes) continue;
if (contact.type != advTypeChat &&
contact.type != advTypeRepeater &&
!settings.mapShowOtherNodes) {
continue;
}
nodeCount++;
}

Copilot AI Feb 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The filter logic for counting nodes in _buildLegend is duplicated from _buildMarkers. This code duplication increases maintenance burden and risk of inconsistencies. Consider extracting this filtering logic into a separate helper method that both _buildMarkers and _buildLegend can call. This would ensure the same filter logic is applied consistently and only needs to be maintained in one place.

Suggested change
Widget _buildLegend(
List<Contact> contactsWithLocation,
settings,
int markerCount,
) {
int nodeCount = 0;
for (final contact in contactsWithLocation) {
// Apply node type filters
if (contact.type == advTypeRepeater && !settings.mapShowRepeaters) {
continue;
}
if (contact.type == advTypeChat && !settings.mapShowChatNodes) continue;
if (contact.type != advTypeChat &&
contact.type != advTypeRepeater &&
!settings.mapShowOtherNodes) {
continue;
}
nodeCount++;
}
bool _shouldIncludeContactOnMap(Contact contact, dynamic settings) {
if (contact.type == advTypeRepeater && !settings.mapShowRepeaters) {
return false;
}
if (contact.type == advTypeChat && !settings.mapShowChatNodes) {
return false;
}
if (contact.type != advTypeChat &&
contact.type != advTypeRepeater &&
!settings.mapShowOtherNodes) {
return false;
}
return true;
}
Widget _buildLegend(
List<Contact> contactsWithLocation,
settings,
int markerCount,
) {
final int nodeCount = contactsWithLocation
.where((contact) => _shouldIncludeContactOnMap(contact, settings))
.length;

Copilot uses AI. Check for mistakes.
@wel97459 wel97459 merged commit 7acfe47 into main Feb 21, 2026
10 checks passed
@wel97459 wel97459 deleted the dev-mapFilters branch March 7, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants