Skip to content

Conversation

SmolSoftBoi
Copy link

  • Introduced plex_default_library property in SettingsService, SettingDto, and Settings entity.
  • Updated LibrarySwitcher and Overview components to utilize the default library setting when switching libraries.
  • Added a dropdown in PlexSettings for selecting the default library from available libraries.

Description

Added a Plex default library setting that allows users to configure which library is automatically selected when visiting the overview page. This includes a new database column plex_default_library in the settings table, a UI setting in the Plex configuration to select the default library, and automatic library selection on the overview page using the configured default with fallback to the first available library if no default is set.

The approach prioritizes backward compatibility and follows established patterns by adding the setting to the existing settings table as a nullable field, ensuring existing installations continue to work without breaking changes. The UI integration places the setting in the Plex configuration page where users expect to find Plex-related settings, and only shows the library dropdown when Plex is authenticated and libraries are available. The implementation updates both the Overview component and LibrarySwitcher to respect the default setting, ensuring consistency across all pages while maintaining the existing "All" option behavior for pages that need it. A proper TypeORM migration ensures clean deployment to existing installations following the established migration naming convention.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my code.
  • I have linted and formatted my code.
  • My changes generate no new warnings.
  • New and existing unit tests pass locally with my changes.

How to test

Please describe the steps to test your changes, including any setup required.

  1. Ensure Plex is properly confugured and authenticated in the application
  2. Have at least 2 differentlibraries in your Plex server
  3. Start the application and verify the migration runs successfully
  4. Check that existing settings are preserved and the new column is added
  5. Navigate to Settings → Plex
  6. Verify the "Default Library" dropdown appears only when Plex is authenticated
  7. Test selecting different libraries from the dropdown
  8. Save changes and verify the setting persists after page refresh
  9. Navigate to the Overview page
  10. Verify it automatically loads the configured default library
  11. Test with no default set - should fall back to first library
  12. Test switching libraries manually - should remember the selection
  13. Verify Collections and Rules pages still show "All" option (unchanged behavior)
  14. Test that manual library selection works correctly
  15. Test with invalid/default library ID (should fall back gracefully)
  16. Test with deleted/removed library (should handle gracefully)
  17. Test application restart preserves the setting
  18. Set a default library, restart the application, and verify it's still selected
  19. Test the complete flow: set default → visit overview → verify auto-selection

…ed components

- Introduced `plex_default_library` property in SettingsService, SettingDto, and Settings entity.
- Updated LibrarySwitcher and Overview components to utilize the default library setting when switching libraries.
- Added a dropdown in PlexSettings for selecting the default library from available libraries.
…ettings, and settings-context components

- Enhanced readability by adjusting line breaks and indentation in the LibrarySwitcher and Overview components.
- Standardized formatting in PlexSettings and settings-context files for better consistency.
@Copilot Copilot AI review requested due to automatic review settings August 19, 2025 01:07
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new Plex default library setting that allows users to configure which library is automatically selected when visiting the overview page. The implementation includes database schema changes, UI components for configuration, and automatic library selection logic.

  • Adds plex_default_library field to settings schema with proper migration
  • Introduces a UI dropdown in Plex settings for selecting default library from available options
  • Updates Overview and LibrarySwitcher components to automatically use the configured default library

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
ui/src/contexts/settings-context.tsx Adds plex_default_library property to settings interface
ui/src/components/Settings/Plex/index.tsx Implements UI dropdown for selecting default library with proper validation
ui/src/components/Overview/index.tsx Updates library selection logic to use default library setting with fallback
ui/src/components/Common/LibrarySwitcher/index.tsx Enhances library switching to respect default library configuration
server/src/modules/settings/settings.service.ts Adds plex_default_library property to settings service
server/src/modules/settings/entities/settings.entities.ts Defines database column for default library setting
server/src/modules/settings/dto's/setting.dto.ts Adds plex_default_library to data transfer object
server/src/database/migrations/1748211262583-Add_plex_default_library.ts Creates migration to add new column to settings table

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

plex_port: +portRef.current.value,
plex_name: nameRef.current.value,
plex_ssl: +sslRef.current.checked, // not used, server derives this from https://
plex_default_library: defaultLibraryRef.current?.value ? +defaultLibraryRef.current.value : undefined,
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

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

The ternary operation converts empty string to undefined, but the type should be consistent with the nullable database field. Consider using null instead of undefined for better consistency with the backend schema.

Suggested change
plex_default_library: defaultLibraryRef.current?.value ? +defaultLibraryRef.current.value : undefined,
plex_default_library: defaultLibraryRef.current?.value ? +defaultLibraryRef.current.value : null,

Copilot uses AI. Check for mistakes.


plex_auth_token: string;

plex_default_library: number;
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

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

The DTO property should be nullable to match the database entity definition. The type should be number | null instead of number to properly represent optional values.

Suggested change
plex_default_library: number;
plex_default_library: number | null;

Copilot uses AI. Check for mistakes.


plex_auth_token: string;

plex_default_library: number;
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

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

The service property should be nullable to match the database entity and DTO. The type should be number | null to properly handle cases where no default library is set.

Suggested change
plex_default_library: number;
plex_default_library: number | null;

Copilot uses AI. Check for mistakes.

- Updated the plex_default_library property in SettingsService, SettingDto, and settings-context to accept null values, enhancing flexibility in settings configuration.
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.

1 participant