Skip to content

Comments

(Remove) Redundant TMDB ID value check that's always true#5269

Merged
Roardom merged 1 commit intoHDInnovations:developmentfrom
Oha-you:reset-ids-fix
Feb 17, 2026
Merged

(Remove) Redundant TMDB ID value check that's always true#5269
Roardom merged 1 commit intoHDInnovations:developmentfrom
Oha-you:reset-ids-fix

Conversation

@Oha-you
Copy link
Contributor

@Oha-you Oha-you commented Feb 11, 2026

To reproduce:

  • Open Torrent Upload form
  • Set Title and some IDs: TMDB movie/TV ID, IMDB ID, MAL ID or TVDB ID
  • Pick a .torrent file
  • Observe that all IDs are reset

Note: this doesn't happen when you change the category first.
But it does happen if you set it on page load with torrents/create?category_id=2

I'm not sure why cat = $refs.catId.value was needed in @change originally for #2243
Because cat is assigned here anyway:

<section
class="upload panelV2"
x-data="{
cat: {{ old('category_id', (int) $category_id) }},
cats: JSON.parse(atob('{{ base64_encode(json_encode($categories)) }}')),

Values are reset because they listen to cat changes:

x-bind:value="cats[cat].type === 'movie' && tmdb_movie_exists ? '{{ old('tmdb_movie_id', $movieId) }}' : ''"

When you change the category from the dropdown list, IDs should reset - this is correct.
Also IDs are retrieved through TMDB API when the Title is not set and .torrent is selected.
But after you fill all the inputs in the upload form yourself, they shouldn't be touched.

@what-the-diff
Copy link

what-the-diff bot commented Feb 11, 2026

PR Summary

  • Removed value assignment in event handler
    Refactored the code to improve efficiency by eliminating the assignment of a value in an event handler for a file input.

@Oha-you
Copy link
Contributor Author

Oha-you commented Feb 11, 2026

Adding another commit here.
Condition in parenthesis always returns true because one of #auto_tmdb_movie or #auto_tmdb_tv values is always NULL depending on whether Movie or TV category is selected:

if (!name.value.trim() && (!tmdb_movie.value.trim() || !tmdb_tv.value.trim())) {

Introduced after the split happened: #4563
Originally this logic was added by me back in 2021: #1760

But I think just checking if the title is set should be enough. I doubt people set DB IDs first when they upload a torrent anyway.

id="torrent"
required
@change="uploadExtension.hook(); cat = $refs.catId.value"
@change="uploadExtension.hook()"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the reason this code is needed is because the uploadExtension.hook() changes #autocat's value, and alpine.js's x-model down below doesn't register this change and update its value, so it has to be done manually.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You were right. But what if we trigger the change event in JS instead of the template?
Please see the updated commit.
Tested it with Movies and TV category selected by default, then added a TV/Movie torrent.
@change event was triggered and DB ID inputs got updated.
This discussion helped: alpinejs/alpine#1388

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd rather keep the explicitness for now. It's impossible to link the event emitters to the event listeners in the code, and at least the way it was before, it was all referenced on the same line. Maybe at some point it can be all moved into alpine. For now, can you revert the changes you made to the category changing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, first commit removed. Also changed the PR title.

@Oha-you Oha-you force-pushed the reset-ids-fix branch 2 times, most recently from ddcdcb1 to eabbb18 Compare February 17, 2026 03:03
@Oha-you Oha-you changed the title (Fix) Don't reset DB IDs when .torrent is selected (Remove) Redundant TMDB ID value check that's always true Feb 17, 2026
@Roardom Roardom merged commit b8b4fb1 into HDInnovations:development Feb 17, 2026
9 checks passed
@Roardom
Copy link
Collaborator

Roardom commented Feb 17, 2026

Thank you!

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