Skip to content

Synchronize DNS provider changes during app startup and reloads - #69

Closed
Himanth-reddy wants to merge 1 commit into
ProdigyV21:mainfrom
Himanth-reddy:dns-reload-optimization
Closed

Synchronize DNS provider changes during app startup and reloads#69
Himanth-reddy wants to merge 1 commit into
ProdigyV21:mainfrom
Himanth-reddy:dns-reload-optimization

Conversation

@Himanth-reddy

Copy link
Copy Markdown
Collaborator

This pull request introduces a robust system for handling DNS provider changes in the app, ensuring that DNS settings are correctly applied at startup and that runtime changes trigger appropriate UI and network updates. The changes span initialization, UI, network, and settings logic, with careful handling to ensure smooth user experience and correct network behavior.

DNS Provider Change Handling and Synchronization:

  • Added logic in ArflixApplication to apply the persisted DNS provider at startup, ensuring the app always uses the correct DNS configuration on launch. Errors during this process are logged. [1] [2]
  • In SettingsViewModel, whenever the DNS provider preference is read, the runtime DNS provider is synchronized with the saved value. A nonce (dns_reload_nonce) is introduced to signal DNS changes. [1] [2] [3]

UI and State Updates on DNS Change:

  • In MainActivity, observes the dns_reload_nonce from DataStore. When it changes (indicating a user-initiated DNS change), the activity is recreated to ensure all components use the new DNS settings. [1] [2]
  • HomeViewModel now observes DNS provider changes and, upon detection, triggers a full reload of home content and clears relevant caches and state, ensuring data consistency with the new DNS configuration. [1] [2]

Network Layer Improvements:

  • In OkHttpProvider, when the DNS provider is set, the connection pool is evicted and any in-flight TMDB API calls are cancelled to prevent stale DNS resolution, improving reliability after DNS changes.

Settings UI Enhancements:

  • Adjusted the settings screen to correctly handle the new DNS provider picker and its position in the UI, including focus and scroll behavior updates. [1] [2] [3] [4] [5]

Build and Dependency Cleanups:

These changes collectively ensure that DNS provider changes are handled safely and efficiently, both at startup and during runtime, with appropriate user interface feedback and network hygiene.

@Himanth-reddy
Himanth-reddy marked this pull request as ready for review March 29, 2026 05:38
@ProdigyV21

Copy link
Copy Markdown
Owner

The DNS reload logic in this PR is sound — applying the persisted provider at startup in ArflixApplication, the dns_reload_nonce signal to trigger activity recreation in MainActivity, evicting the OkHttp connection pool and cancelling in-flight TMDB calls in OkHttpProvider on provider change, and reloading home content / clearing caches in HomeViewModel all look reasonable.

However, this PR is currently not mergeable — it's in a CONFLICTING / DIRTY state against main. The areas it touches (MainActivity, SettingsScreen, HomeViewModel, SettingsViewModel) have had significant churn from other recently merged PRs, so the branch has drifted.

To unblock merge:

  1. Rebase on latest main and resolve conflicts. Expect conflicts at minimum in:

    • app/src/main/kotlin/com/arflix/tv/MainActivity.kt (device-mode handling was recently updated)
    • app/src/main/kotlin/com/arflix/tv/ui/screens/settings/SettingsScreen.kt (new rows and dialogs have been added in Add UI Mode Warning Dialog and Handle Device Mode Changes #120 and other merged PRs — DNS Provider row position and the General-section focus/clamp indices will need to be reconciled)
    • app/src/main/kotlin/com/arflix/tv/ui/screens/home/HomeViewModel.kt
    • app/src/main/kotlin/com/arflix/tv/ui/screens/settings/SettingsViewModel.kt
  2. Re-run the Release Gate CI after rebasing. The previous green check is stale because it ran against an older base.

  3. While you're rebasing, please double-check the two small build-config edits (app/build.gradle.kts and settings.gradle.kts) are still needed on current main — they may already be redundant.

Once it's rebased, CI is green again, and the DNS Provider row is still reachable via D-pad in the updated General section (same recurring gotcha as the other settings-touching PRs), this should be ready to merge. The underlying logic is fine — it's purely a rebase/conflict issue.

- Bootstrap the persisted DNS provider during app startup
- Trigger activity recreation only for explicit user DNS change events
- Cancel TMDB calls, rebuild Coil, and force home content reload after DNS switches
- Keep DNS preference application in sync and retain related settings/debug module adjustments
@Himanth-reddy
Himanth-reddy deleted the dns-reload-optimization branch April 12, 2026 17:18
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