Skip to content

BaseItemDto Editing Cleanup#1870

Open
JPKribs wants to merge 31 commits intojellyfin:mainfrom
JPKribs:editMetadataError
Open

BaseItemDto Editing Cleanup#1870
JPKribs wants to merge 31 commits intojellyfin:mainfrom
JPKribs:editMetadataError

Conversation

@JPKribs
Copy link
Member

@JPKribs JPKribs commented Dec 21, 2025

Summary

Resolves: #1869

While trying to resolve #1869, I wanted to convert over the ItemEditorViewModel and it's extensions to use the new @Stateful macros. This led me to the views themselves which I created about a year ago. With what I know now, there is some room for improvement. The primary changes made:

  1. Move all Item Permissions from the UserSession to the BaseItemDto. The current usage of this was pretty bulky and required getting the permissions from a separate location using the item as an input. Instead, this just puts the permissions directly on the BaseItemDto since that's the only place where these can be used anyway.
  2. Hide the PlayButton if the user does not have permission to play content from Jellyfin. I don't imagine this comes up often. I am only aware of this because I have an admin account that doesn't have playback permission and this button throws a non-descriptive error from the server. Hiding the button seems like the cleaner solution.
  3. Unified ItemEditorMenu struct. The menu dropdown items are the same between iOS and tvOS (kind of) so this lets us keep all the permission logic and routing in a single spot for later.
  4. A more detailed ItemDeletionView. Especially for Series, it can be hard to determine what specifically you are deleting. This gives the full count of items deleted, and the type/details. This should help prevent any heartache where someone thinks they are deleting an episode but delete a series.
  5. For the EditItemElementViewModelss, I've changef this from using a trie to instead just do a search and debounce. This is more performant for items where searching is available. Tags cannot do this so that will still use the trie.
  6. EditItemElementViews, was broken where I could re-add the same genre, tag, studio, or person unlimited times. This blocks adding duplicates to the same item now.
  7. Moved AdminDashboardView/Components/MediaItemSection.swift -> /Components/ItemFormSection.swift since this is used outside of the AdminDashboard now. It's a good way to display BaseItemDto in a form so this helps with re-use.
  8. Removed the progress on RefreshMetadataViewModel since we don't have the progress anymore. Eventually, most of this will be deleted since the websocket will be able to get the refreshed item instead of use counting to 5 and manually refreshing.
  9. The ConnecToServerView -> ConnectToServerView typo fix.
  10. Instead of doing many permission checks throughout the ItemEditorView I'm just purely leaving that as admin edit actions and moving subtitles (non-admin) and refresh Metadata functionality to the dropdown. It makes the permissions a bit easier to handle and centralizes the tvOS and iOS permission checks.
  11. Added a dummy navigationBarCloseButton for tvOS. We can make one here but I don't see a benefit since the natural interaction is the back button.
  12. Cleanup in the same fashion for AddServerUserAccessTagsView since we are doing tag searches with the same ViewModel there so that should reflect the Metadata editing

TODOs

  • I wanted to move the DeleteItemViewModel over to use the new @Stateful macros but I think this ViewModel should just get rolled into either ItemEditorViewModel or ItemViewModel instead. I held off until after Posters, Libraries, Home #1752 if that is the best route. I just feel as though a whole ViewModel for a single deletion function is overkill.

Videos

Please note these only return a 404 because the test file I am using doesn't exist. I added the entry manually so there is no actual file to delete hence 404

tvOS

Simulator.Screen.Recording.-.Apple.TV.-.2025-12-21.at.00.50.30.mov

iOS

Simulator.Screen.Recording.-.iPhone.-.2025-12-21.at.14.33.01.mov

Image

iOS Episode Simulator Screenshot - iPhone - 2025-12-21 at 01 01 10
tvOS Series Simulator Screenshot - Apple TV - 2025-12-21 at 00 50 46

@JPKribs JPKribs added iOS Impacts iOS or iPadOS tvOS Impacts tvOS bug Something isn't working developer Alters the developer experience labels Dec 21, 2025
@JPKribs JPKribs marked this pull request as draft December 21, 2025 04:30
@JPKribs JPKribs marked this pull request as ready for review December 21, 2025 08:23
@JPKribs JPKribs changed the title [WIP] BaseItemDto Editing Cleanup BaseItemDto Editing Cleanup Dec 21, 2025
@JPKribs
Copy link
Member Author

JPKribs commented Dec 21, 2025

This is a weird one. It's all kind of interconnected. There are some smaller ones I could break out like moving permissions over to the BaseItemDto but that's a fairly small part of this. Most of this work is the migration of the ItemEditorViewModel to @Stateful but there is 4x the work since we have 4x extensions on this that all need the same changes.

If there's anything we'd rather split out let me know. The goal was originally to fix #1869 but I kept finding things that needed clean up.

The only part of this I'm not 100% confident in is the ItemEditorMenu. I like that it centralizes all of our editing logic and permission checks into 1 spot for both iOS and tvOS. It's much much cleaner BUT I don't know if making a struct for Menu Contents is good swift programming.

@JPKribs JPKribs mentioned this pull request Dec 23, 2025
@JPKribs JPKribs force-pushed the editMetadataError branch from 0e0c84e to a1ea7bd Compare January 2, 2026 21:14
JPKribs added 14 commits January 2, 2026 14:19
…chView`. This will be used in both `AddItemElementView` and `AddServerUserAccessTagsView`
…l` have been rolled into `ItemEditorViewModel`
…s `ErrorView`.

- Use `ErrorView` for `viewModel.state.content`
- Use `.errorMessage($viewModel.error)` for `viewModel.events`.

If there is no `.content`, IE the content is the full `BaseItemDto` which is already included, only have a `.errorMessage`. If there are no `.events` that we are looking for, don't include `.errorMessage`
@JPKribs JPKribs force-pushed the editMetadataError branch from a1ea7bd to 7342600 Compare January 2, 2026 21:19
JPKribs and others added 5 commits January 7, 2026 17:17
# Conflicts:
#	Shared/Objects/UserPermissions.swift
#	Shared/ViewModels/ItemAdministration/DeleteItemViewModel.swift
#	Shared/ViewModels/ItemAdministration/ItemEditorViewModel/GenreEditorViewModel.swift
#	Translations/en.lproj/Localizable.strings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working developer Alters the developer experience iOS Impacts iOS or iPadOS tvOS Impacts tvOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to edit item metadata

2 participants