fix(hubs): keep recently-added detail scoped to its library

close #1282
This commit is contained in:
edde746
2026-06-08 22:03:28 +02:00
parent d44a8994ce
commit 7de7802368
5 changed files with 97 additions and 11 deletions
+9 -2
View File
@@ -2,6 +2,11 @@ import 'json_utils.dart';
final RegExp plexLibrarySectionPathPattern = RegExp(r'/(?:library|hubs)/sections/(\d+)');
/// Matches a section id carried in a query string rather than the path, e.g.
/// `/hubs/home/recentlyAdded?type=2&sectionID=2`. The `[?&]` anchor keeps it from
/// false-matching a path segment; the alternation also accepts `librarySectionID=`.
final RegExp plexLibrarySectionQueryPattern = RegExp(r'[?&](?:librarySectionID|sectionID)=(\d+)');
int? plexLibrarySectionIdFromJson(Map<String, dynamic>? json) {
if (json == null) return null;
final direct = flexibleInt(json['librarySectionID']) ?? flexibleInt(json['targetLibrarySectionID']);
@@ -18,8 +23,10 @@ int? plexLibrarySectionIdFromString(String? value) {
if (value == null || value == 'shared') return null;
final direct = int.tryParse(value);
if (direct != null) return direct;
final match = plexLibrarySectionPathPattern.firstMatch(value);
return match == null ? null : int.tryParse(match.group(1)!);
final pathMatch = plexLibrarySectionPathPattern.firstMatch(value);
if (pathMatch != null) return int.tryParse(pathMatch.group(1)!);
final queryMatch = plexLibrarySectionQueryPattern.firstMatch(value);
return queryMatch == null ? null : int.tryParse(queryMatch.group(1)!);
}
String? plexLibrarySectionTitleFromJson(Map<String, dynamic>? json) {