fix: correct type checking and imports in filtered library page

- Add shelfsdk import to router.dart for Filter types
- Fix Media and MediaMetadata type checking using freezed mapOrNull
- Handle all Media variants (book, bookMinified, bookExpanded)
- Handle all MediaMetadata variants to extract title, subtitle, and authors
- Fix BookMetadata accessing authors list instead of authorName property

Resolves compilation errors in GitHub Actions build.
This commit is contained in:
Claude 2025-11-20 16:54:06 +00:00
parent 43712643a2
commit 8300cc7571
No known key found for this signature in database
2 changed files with 76 additions and 18 deletions

View file

@ -113,24 +113,81 @@ class LibraryItemListTile extends ConsumerWidget {
String? subtitle; String? subtitle;
String? authorName; String? authorName;
if (media is MediaBook) { // Use map to handle Media variants
final metadata = media.metadata; media.mapOrNull(
if (metadata is BookMetadata) { book: (book) {
title = metadata.title ?? 'Unknown'; final metadata = book.metadata;
subtitle = metadata.subtitle; metadata.mapOrNull(
authorName = metadata.authorName; book: (m) {
} else if (metadata is BookMetadataMinified) { title = m.title ?? 'Unknown';
title = metadata.title ?? 'Unknown'; subtitle = m.subtitle;
authorName = metadata.authorName; if (m.authors.isNotEmpty) {
} else if (metadata is BookMetadataExpanded) { authorName = m.authors.map((a) => a.name).join(', ');
title = metadata.title ?? 'Unknown'; }
subtitle = metadata.subtitle; },
final authors = metadata.authors; bookMinified: (m) {
if (authors != null && authors.isNotEmpty) { title = m.title ?? 'Unknown';
authorName = authors.map((a) => a.name).join(', '); subtitle = m.subtitle;
} authorName = m.authorName;
} },
} bookExpanded: (m) {
title = m.title ?? 'Unknown';
subtitle = m.subtitle;
if (m.authors.isNotEmpty) {
authorName = m.authors.map((a) => a.name).join(', ');
}
},
);
},
bookMinified: (book) {
final metadata = book.metadata;
metadata.mapOrNull(
book: (m) {
title = m.title ?? 'Unknown';
subtitle = m.subtitle;
if (m.authors.isNotEmpty) {
authorName = m.authors.map((a) => a.name).join(', ');
}
},
bookMinified: (m) {
title = m.title ?? 'Unknown';
subtitle = m.subtitle;
authorName = m.authorName;
},
bookExpanded: (m) {
title = m.title ?? 'Unknown';
subtitle = m.subtitle;
if (m.authors.isNotEmpty) {
authorName = m.authors.map((a) => a.name).join(', ');
}
},
);
},
bookExpanded: (book) {
final metadata = book.metadata;
metadata.mapOrNull(
book: (m) {
title = m.title ?? 'Unknown';
subtitle = m.subtitle;
if (m.authors.isNotEmpty) {
authorName = m.authors.map((a) => a.name).join(', ');
}
},
bookMinified: (m) {
title = m.title ?? 'Unknown';
subtitle = m.subtitle;
authorName = m.authorName;
},
bookExpanded: (m) {
title = m.title ?? 'Unknown';
subtitle = m.subtitle;
if (m.authors.isNotEmpty) {
authorName = m.authors.map((a) => a.name).join(', ');
}
},
);
},
);
final imageUrl = apiSettings.activeServer != null final imageUrl = apiSettings.activeServer != null
? '${apiSettings.activeServer!.serverUrl}/api/items/${item.id}/cover' ? '${apiSettings.activeServer!.serverUrl}/api/items/${item.id}/cover'

View file

@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:shelfsdk/audiobookshelf_api.dart';
import 'package:vaani/features/downloads/view/downloads_page.dart'; import 'package:vaani/features/downloads/view/downloads_page.dart';
import 'package:vaani/features/explore/view/explore_page.dart'; import 'package:vaani/features/explore/view/explore_page.dart';
import 'package:vaani/features/explore/view/search_result_page.dart'; import 'package:vaani/features/explore/view/search_result_page.dart';