Skip to content

Conversation

@jigar-f
Copy link
Contributor

@jigar-f jigar-f commented Jan 20, 2026

This pull request introduces a set of improvements to Lantern's background event handling, especially for data cap updates, and refactors how background listeners are managed. The changes enable real-time updates of data cap information via background listeners, simplify the listener management logic, and clean up unused or redundant code in the Flutter UI. Additionally, there are minor dependency updates and logging adjustments.

The most important changes are:

Background Listener Refactoring and Enhancements:

  • Replaces StartAutoLocationListener/StopAutoLocationListener with generalized StartBackgroundListeners/StopBackgroundListeners methods in the App interface and throughout the codebase, consolidating background event management for both server location and data cap updates. (lantern-core/core.go, lantern-core/mobile/mobile.go) [1] [2] [3] [4] [5] [6] [7]
  • Adds a new background listener for data cap changes (listeningDataCapChanges), subscribing to data cap events and notifying the Flutter frontend in real time. (lantern-core/core.go) [1] [2] [3]

Data Cap Info Streaming and UI Updates:

  • Implements a new DataCapStream method in the User interface for streaming data cap updates, and wires it into the background listener logic. (lantern-core/core.go) [1] [2]
  • Updates the Flutter Riverpod provider and app event notifier to handle data-cap-event messages, updating the data cap info in the UI as soon as events are received. (lib/features/home/provider/app_event_notifier.dart, lib/features/home/provider/data_cap_info_provider.dart) [1] [2]
  • Removes redundant lifecycle and route observer logic from the Home widget, since data cap info is now updated reactively via events instead of manual refreshes. (lib/features/home/home.dart) [1] [2] [3]

Minor Refactors and Dependency Updates:

  • Updates the github.com/getlantern/amp dependency version in go.mod.
  • Changes log level from trace to debug in the macOS app delegate for less verbose logging. (macos/Runner/AppDelegate.swift)
  • Minor code cleanup, such as commenting out excessive logging in the DataUsage widget. (lib/features/home/data_usage.dart)

These changes improve the responsiveness and maintainability of the app by centralizing event handling and ensuring that data cap usage is always up to date in the UI.

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