Fix local API search erroring, because the default parameter values were not getting applied #4704
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.
Fix local API search erroring, because the default parameter values were not getting applied
Pull Request Type
Related issue
closes #4703 (discussion will have to be closed manually because github only supports automatically closing issues and pull requests)
Description
This pull request only fixes the search, it does not fix the watch page, that will require a different fix.
Previously the default values for the
createInnertube
function were only being set, if no options were passed in. As the search passes in thesafetyMode
setting, this mean that none of the defaults were getting applied.generateSessionLocally
is meant to default totrue
, but as the defaults were only getting applied when no options were passed in that meant thatgenerateSessionLocally
was actuallyundefined
for the search,undefined
is falsey, so we were actually generating a real session for every search that the user made.This pull request changes the code so that the the defaults are applied on a parameter level instead of only when the entire options object is missing.
Testing
Search with the local API. No errors should show up and in the devtools you should only see a request to the
/search
endpoint (previously it did an extra unintended request to sw.js_data).Desktop