fix(android): skip addon stream warmup when prepare links is off#1303
Open
DynamycSound wants to merge 1 commit into
Open
fix(android): skip addon stream warmup when prepare links is off#1303DynamycSound wants to merge 1 commit into
DynamycSound wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
With "Resolve playable links" enabled but "Prepare links" turned off (links-to-prepare count = 0), opening a movie/episode details page still fired stream requests to every enabled add-on. This PR makes the ahead-of-time add-on stream warmup respect the "Prepare links" setting, so no add-on requests are sent on the details page until the user presses Play.
Why
AddonStreamWarmupRepositorywarms add-on streams on the details screen (MetaDetailsScreencallsAddonStreamWarmupRepository.preload(...)in aLaunchedEffect). Its only purpose is to feedDirectDebridStreamPreparer.prepare(), which prepares debrid links ahead of playback.DirectDebridStreamPreparer.prepare()already early-returns when the prepare-links limit is 0:But the warmup gate (
AddonStreamWarmupRepository.currentKey) only checkedcanResolvePlayableLinksand the TorBox key — it never checkedinstantPlaybackPreparationLimit. So with "Prepare links" disabled, the warmup still queried every enabled add-on for streams on details-page open, then handed them to a preparer that immediately did nothing. This produces premature add-on requests, and pressing Play shortly after opening the page issues a second, duplicate stream request (the warmup fetch plus the streams-screen fetch), hammering indexers twice.The "Prepare links" setting description states "Resolve playable links before playback starts," and its warning explicitly documents that "opening a movie or episode can count toward those limits even if you do not press Watch, because the links are prepared ahead of time." Disabling it should therefore stop all ahead-of-time work, including the add-on warmup.
The fix adds a
DebridSettings.instantPlaybackPreparationEnabledproperty (canResolvePlayableLinks && instantPlaybackPreparationLimit > 0) — mirroring the gateDirectDebridStreamPreparer.prepare()already enforces — and makes the warmup gate use it. The warmup-cache consumers (StreamsRepository,PlayerStreamsRepository) already treat a missing warmup cache as a normal cache miss (.orEmpty()→ loading placeholders), so disabling the warmup simply falls back to fetching streams when the user opens the stream list.Issue or approval
Fixes #1299
UI / behavior impact
Policy check
PR type
Scope boundaries
composeApp/src/commonMain/kotlin/com/nuvio/app/features/debrid/DebridSettings.kt— adds theinstantPlaybackPreparationEnabledcomputed property (canResolvePlayableLinks && instantPlaybackPreparationLimit > 0).composeApp/src/commonMain/kotlin/com/nuvio/app/features/streams/AddonStreamWarmupRepository.kt— the warmup gate incurrentKey()now returns null (no warmup) unlessinstantPlaybackPreparationEnabledis true (TorBox-key requirement unchanged).composeApp/src/commonTest/kotlin/com/nuvio/app/features/debrid/DebridSettingsTest.kt— adds two tests for the new property.No other behavior is touched; when "Prepare links" is enabled (limit > 0) the warmup behaves exactly as before.
Testing
./gradlew :composeApp:assembleFullDebug— ✅ BUILD SUCCESSFUL./gradlew :composeApp:testFullDebugUnitTest— ✅ all passingDebridSettingsTest:instant playback preparation stays disabled when the prepare links count is zero— assertscanResolvePlayableLinks == truebutinstantPlaybackPreparationEnabled == falsewheninstantPlaybackPreparationLimit = 0(reproduces the bug condition: warmup would previously have run).instant playback preparation requires a positive prepare links count and a resolver— asserts it's enabled only with a positive limit and a configured resolver.STATIC ANALYSIS:
MetaDetailsScreen→AddonStreamWarmupRepository.preload(...)→currentKey()returned a non-null key whenevercanResolvePlayableLinksand a TorBox key were present, regardless ofinstantPlaybackPreparationLimit. The warmup then fetched streams from every enabled add-on, even thoughDirectDebridStreamPreparer.prepare()immediately returns when the limit is 0 — so the add-on requests were sent for no effect.currentKey()returns null wheninstantPlaybackPreparationLimit <= 0, sopreload()performs no add-on requests. Add-on stream requests are then only issued when the user opens the stream list / presses Play.instantPlaybackPreparationEnabledimpliescanResolvePlayableLinks); no TorBox key → still returns null.Screenshots / Video
Not a UI change.
Breaking changes
None.
Linked issues
Fixes #1299