Skip to content

fix: resolve crashes and debug filter issues in Metrics and MapView#4824

Merged
jamesarich merged 3 commits intomainfrom
fix/crashes
Mar 17, 2026
Merged

fix: resolve crashes and debug filter issues in Metrics and MapView#4824
jamesarich merged 3 commits intomainfrom
fix/crashes

Conversation

@jamesarich
Copy link
Copy Markdown
Collaborator

This pull request introduces several improvements and cleanups across the codebase, focusing on dependency injection, code simplification, and bug fixes. The most significant changes are in how MetricsViewModel is provided with parameters in navigation, dependency injection verification, and some resource import cleanups.

Dependency Injection and ViewModel Improvements:

  • Updated the navigation logic to provide MetricsViewModel with a unique key and the required destNum parameter using Koin's parametersOf in all relevant navigation entries, ensuring correct instance scoping and parameter passing. [1] [2] [3]
  • Enhanced the Koin verification test to include parameterized injection for MetricsViewModel, improving test coverage for dependency injection.
  • Added the import for MetricsViewModel in the Koin verification test file.

Code Simplification and Cleanup:

  • Removed unused or unnecessary imports in MapView.kt and MapViewModel.kt, reducing clutter and potential confusion. [1] [2] [3] [4] [5]
  • Refactored the nodeRepository property in MapViewModel and BaseMapViewModel to remove the override modifier and adjust visibility, simplifying inheritance and property usage. [1] [2]
  • Removed an unused override function from MapViewModel for additional code clarity.

Bug Fixes:

  • Fixed a bug in MapView.kt where subDescription could be set with a null bearing by ensuring the bearing is non-null before using it.

Other Improvements:

  • Improved log filtering logic in DebugViewModel by correcting the direction of string containment checks, making the filter behavior more intuitive and reliable.

resolves #4810
resolves #4812
resolves #4821

Fix #4810: Debug Panel preset filters return empty results
- The filterLogs() method had reversed contains() checks - it was
  checking if the short filter text contained the long log message,
  which almost always returns false. Corrected to check if log fields
  contain the filter text.
Fix #4821: App crashes when requesting history data / traceroute
- MetricsViewModel requires @InjectedParam destNum: Int, but the
  Nav3 navigation entries were calling koinViewModel<MetricsViewModel>()
  without passing destNum via parametersOf(). This causes a Koin
  injection crash at runtime. Fixed all 3 call sites to match the
  Desktop implementation pattern: koinViewModel(key = ...) { parametersOf(destNum) }.
- Updated KoinVerificationTest to declare MetricsViewModel's Int
  parameter so future regressions are caught.
The map_subDescription string resource uses %1$d (integer) for the
bearing parameter, but the code was passing ourNode.bearing(node).toString()
which converts the Int? to a String. This caused a crash:
IllegalFormatConversionException: d != java.lang.String
Fix: Remove .toString() and pass the Int directly. Also safely handle
the nullable bearing() return with ?.let to avoid passing null.
Fixes crash in MapView.onNodesChanged() at line 447.
This commit cleans up the map ViewModel hierarchy by removing unnecessary property overrides and redundant methods in the `fdroid` flavor implementation.

Specific changes include:
- **BaseMapViewModel**: Removed the `open` modifier from `nodeRepository` to prevent unnecessary overrides.
- **MapViewModel (fdroid)**:
    - Removed the `override` modifier from `nodeRepository` in the constructor.
    - Removed the redundant `getUser` override as the base implementation now suffices.
- **MapView (fdroid)**: Removed an unused import for `toString`.

Signed-off-by: James Rich <[email protected]>
@jamesarich jamesarich enabled auto-merge March 17, 2026 13:45
@github-actions github-actions bot added the bugfix PR tag label Mar 17, 2026
@jamesarich jamesarich added this pull request to the merge queue Mar 17, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 7.69231% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 13.20%. Comparing base (9ad28e9) to head (a570f8f).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...astic/feature/settings/debugging/DebugViewModel.kt 0.00% 10 Missing ⚠️
...n/org/meshtastic/app/navigation/NodesNavigation.kt 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4824      +/-   ##
==========================================
- Coverage   13.20%   13.20%   -0.01%     
==========================================
  Files         539      539              
  Lines       17761    17763       +2     
  Branches     2651     2651              
==========================================
  Hits         2345     2345              
- Misses      15100    15102       +2     
  Partials      316      316              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Merged via the queue into main with commit a10fe61 Mar 17, 2026
7 checks passed
@jamesarich jamesarich deleted the fix/crashes branch March 17, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag

Projects

None yet

1 participant