Skip to content

fix: Rule editor errors when not using rule system#2270

Merged
benscobie merged 1 commit into
mainfrom
fix-empty-rule-handling
Jan 10, 2026
Merged

fix: Rule editor errors when not using rule system#2270
benscobie merged 1 commit into
mainfrom
fix-empty-rule-handling

Conversation

@benscobie

Copy link
Copy Markdown
Contributor

No description provided.

@benscobie benscobie merged commit 730adb5 into main Jan 10, 2026
10 checks passed
@benscobie benscobie deleted the fix-empty-rule-handling branch January 10, 2026 20:56
enoch85 added a commit to enoch85/Maintainerr that referenced this pull request Jan 12, 2026
This commit completes the merge from main that was started in 0923d01.
The original merge included the leftJoinAndSelect changes but missed
removing the empty rule creation code from rules.service.ts.

Backend (rules.service.ts):
- Remove empty rule creation in createRuleGroup and updateRuleGroup
- When useRules=false, the backend was creating rules with empty ruleJson
- This aligns with main's fix from commit 730adb5 (Maintainerr#2270)
- The RemoveEmptyRules migration (already present) cleans up existing data

Frontend (RuleFormPage.tsx):
- Add key={id} prop to AddModal component
- This ensures the form fully remounts when navigating between rule groups
- Replaces the need for useEffect-based form reset logic

Frontend (AddModal/index.tsx):
- Remove parseValidRules helper (no longer needed since empty rules won't exist)
- Remove defensive firstVal check in filterRulesForArrSettings
- Simplify rules state initialization to direct parsing

The root cause was that commit 0923d01 merged the query changes
(leftJoinAndSelect for rules) but not the corresponding code removal
that prevents empty rules from being created in the first place.
@jorenn92

Copy link
Copy Markdown
Member

🎉 This PR is included in version 2.26.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

ydkmlt84 pushed a commit that referenced this pull request Jan 31, 2026
* feat: Add Jellyfin support with abstraction layer

- Add MediaServerService abstraction for Plex/Jellyfin
- Implement JellyfinService with full API integration
- Update rules engine to support multiple media servers
- Add Jellyfin settings UI and configuration
- Refactor collections to use MediaServerService
- Add comprehensive type safety improvements
- Update database schema for media server support

* snc against this branch instead

* feat(api): add deprecated /api/plex legacy wrapper for backward compatibility

- Add PlexApiLegacyController with all 19 original endpoints
- All endpoints delegate to MediaServerFactory abstraction
- Add deprecation headers (X-Deprecated, Deprecation, Link)
- Uses MediaServerSetupGuard (works with both Plex and Jellyfin)
- Maps old route patterns to new abstraction interface
- Single file design for easy removal when legacy support ends

To remove legacy support: delete plex-api-legacy.controller.ts and
remove PlexApiLegacyController from plex-api.module.ts

* chore: merge main branch changes

- Use leftJoinAndSelect for rules (allows groups without rules)
- Delete unused CollectionDetail/index.tsx
- Use useRuleGroupForCollection hook instead of manual fetch
- Conditionally show Test Media button only when useRules=true
- Simplify addCollectionToDB and RemoveCollectionFromDB methods

* fix: update SchemaSync migration to use mediaServerId instead of plexId

The SchemaSync migration from main referenced plexId (integer) but our
JellyfinSupport migration already renamed this to mediaServerId (varchar).
Updated both UP and DOWN methods to use the correct column name and type.

* regenerated with typeorm

* fix: standardize quotation marks and formatting in SchemaSync migration

* generate clean typeorm

* fix(ui): filter out empty/invalid rules to prevent crash

When useRules=false, the backend creates a rule with empty ruleJson.
These rules have no firstVal, causing TypeError when shouldFilterApp
tries to access rule.firstVal[0].

Refactored to remove all useEffect usage:
- Use useSyncExternalStore for scroll detection (React 19 pattern)
- Move rule filtering to event handlers (updateLibraryId, handleUpdateArrAction)
- Extract helper functions outside component (parseValidRules, shouldFilterApp, filterRulesForArrSettings)

This is cleaner and more aligned with modern React patterns.

* fix: complete merge of main branch rule editor fixes

This commit completes the merge from main that was started in 0923d01.
The original merge included the leftJoinAndSelect changes but missed
removing the empty rule creation code from rules.service.ts.

Backend (rules.service.ts):
- Remove empty rule creation in createRuleGroup and updateRuleGroup
- When useRules=false, the backend was creating rules with empty ruleJson
- This aligns with main's fix from commit 730adb5 (#2270)
- The RemoveEmptyRules migration (already present) cleans up existing data

Frontend (RuleFormPage.tsx):
- Add key={id} prop to AddModal component
- This ensures the form fully remounts when navigating between rule groups
- Replaces the need for useEffect-based form reset logic

Frontend (AddModal/index.tsx):
- Remove parseValidRules helper (no longer needed since empty rules won't exist)
- Remove defensive firstVal check in filterRulesForArrSettings
- Simplify rules state initialization to direct parsing

The root cause was that commit 0923d01 merged the query changes
(leftJoinAndSelect for rules) but not the corresponding code removal
that prevents empty rules from being created in the first place.

* replace more useEffect usage

* prettier

* refactor(ui): replace JS touch detection with CSS media queries

- Remove unused useInteraction, useIsTouch hooks and InteractionContext
- Add CSS @media (hover: hover/none) for touch-friendly MediaCard
- Simplify MediaCard: click always opens modal, CSS handles hover states
- Reduces bundle size by ~150 lines of JS with 15 lines of CSS

* fix click behaviour on mobile

* fix bug on about page showing 0 items in collections

* add support for retrieving seasons and episode view counts

* retrieve admin user ID for UserData fields in getSeasons and getItems

* fix: make watchedAt optional in WatchRecord interface

* add temporary debug for viewdate

* more temp debug

* possible fix for viewdate season/episodes

* prettier

* feat: add getPlaylistItems method to JellyfinAdapterService and update JellyfinGetterService to utilize it

* fix cd/ci tests
ydkmlt84 pushed a commit that referenced this pull request Jan 31, 2026
* feat: Add Jellyfin support with abstraction layer

- Add MediaServerService abstraction for Plex/Jellyfin
- Implement JellyfinService with full API integration
- Update rules engine to support multiple media servers
- Add Jellyfin settings UI and configuration
- Refactor collections to use MediaServerService
- Add comprehensive type safety improvements
- Update database schema for media server support

* snc against this branch instead

* feat(api): add deprecated /api/plex legacy wrapper for backward compatibility

- Add PlexApiLegacyController with all 19 original endpoints
- All endpoints delegate to MediaServerFactory abstraction
- Add deprecation headers (X-Deprecated, Deprecation, Link)
- Uses MediaServerSetupGuard (works with both Plex and Jellyfin)
- Maps old route patterns to new abstraction interface
- Single file design for easy removal when legacy support ends

To remove legacy support: delete plex-api-legacy.controller.ts and
remove PlexApiLegacyController from plex-api.module.ts

* chore: merge main branch changes

- Use leftJoinAndSelect for rules (allows groups without rules)
- Delete unused CollectionDetail/index.tsx
- Use useRuleGroupForCollection hook instead of manual fetch
- Conditionally show Test Media button only when useRules=true
- Simplify addCollectionToDB and RemoveCollectionFromDB methods

* fix: update SchemaSync migration to use mediaServerId instead of plexId

The SchemaSync migration from main referenced plexId (integer) but our
JellyfinSupport migration already renamed this to mediaServerId (varchar).
Updated both UP and DOWN methods to use the correct column name and type.

* regenerated with typeorm

* fix: standardize quotation marks and formatting in SchemaSync migration

* generate clean typeorm

* fix(ui): filter out empty/invalid rules to prevent crash

When useRules=false, the backend creates a rule with empty ruleJson.
These rules have no firstVal, causing TypeError when shouldFilterApp
tries to access rule.firstVal[0].

Refactored to remove all useEffect usage:
- Use useSyncExternalStore for scroll detection (React 19 pattern)
- Move rule filtering to event handlers (updateLibraryId, handleUpdateArrAction)
- Extract helper functions outside component (parseValidRules, shouldFilterApp, filterRulesForArrSettings)

This is cleaner and more aligned with modern React patterns.

* fix: complete merge of main branch rule editor fixes

This commit completes the merge from main that was started in 0923d01.
The original merge included the leftJoinAndSelect changes but missed
removing the empty rule creation code from rules.service.ts.

Backend (rules.service.ts):
- Remove empty rule creation in createRuleGroup and updateRuleGroup
- When useRules=false, the backend was creating rules with empty ruleJson
- This aligns with main's fix from commit 730adb5 (#2270)
- The RemoveEmptyRules migration (already present) cleans up existing data

Frontend (RuleFormPage.tsx):
- Add key={id} prop to AddModal component
- This ensures the form fully remounts when navigating between rule groups
- Replaces the need for useEffect-based form reset logic

Frontend (AddModal/index.tsx):
- Remove parseValidRules helper (no longer needed since empty rules won't exist)
- Remove defensive firstVal check in filterRulesForArrSettings
- Simplify rules state initialization to direct parsing

The root cause was that commit 0923d01 merged the query changes
(leftJoinAndSelect for rules) but not the corresponding code removal
that prevents empty rules from being created in the first place.

* replace more useEffect usage

* prettier

* refactor(ui): replace JS touch detection with CSS media queries

- Remove unused useInteraction, useIsTouch hooks and InteractionContext
- Add CSS @media (hover: hover/none) for touch-friendly MediaCard
- Simplify MediaCard: click always opens modal, CSS handles hover states
- Reduces bundle size by ~150 lines of JS with 15 lines of CSS

* fix click behaviour on mobile

* fix bug on about page showing 0 items in collections

* add support for retrieving seasons and episode view counts

* retrieve admin user ID for UserData fields in getSeasons and getItems

* fix: make watchedAt optional in WatchRecord interface

* add temporary debug for viewdate

* more temp debug

* possible fix for viewdate season/episodes

* prettier

* feat: add getPlaylistItems method to JellyfinAdapterService and update JellyfinGetterService to utilize it

* fix cd/ci tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants