worldhopper/lib/providers/feed_provider.dart
Felipe M. 58a562abe8
feat: refactor server software abstraction with Kavita REST API integration
Rename all OPDS-prefixed models to generic names (Server, Feed, Entry,
Link, StreamLink), expand the ServerSoftware interface to cover all
server interactions, and implement a full Kavita REST API client that
replaces the OPDS delegation.

- Rename OPDS* models to generic names across ~60 files
- Add database migrations 13 (opds_id → entry_id) and 14 (unify credentials)
- Create OPDSServerSoftware wrapping existing OPDS services
- Create KavitaApiClient for direct Kavita REST API calls
- Create KavitaFeedMapper to convert Kavita JSON to Feed/Entry models
- Rewrite KavitaServerSoftware to use native API (no OPDS delegation)
- Unify server credentials (remove softwareUsername/softwarePassword)
- Simplify add/edit server UI to single auth section
- Add test connection button to server add/edit screens
- Add progress indicator to PublicationCard using local and server data
- Eliminate softwareType branching in reader screens
- Add EntryProgress and fetchEntryProgress to ServerSoftware interface
- Fix Entry.acquisitionLink crash on empty links
- Add 59 new tests covering models, services, and providers
2026-04-06 17:46:48 +02:00

78 lines
2.1 KiB
Dart

import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:worldhopper/models/feed.dart';
import 'package:worldhopper/repositories/feed_repository.dart';
/// Provider for FeedRepository instance
final feedRepositoryProvider = Provider<FeedRepository>((ref) {
return FeedRepository();
});
/// Provider for fetching a feed from a server
final feedProvider = FutureProvider.family<Feed, FeedRequest>(
(ref, request) async {
final repository = ref.watch(feedRepositoryProvider);
return await repository.fetchFeed(
request.serverId,
request.url,
forceRefresh: request.forceRefresh,
);
},
);
/// Provider for fetching the root feed of a server
final rootFeedProvider = FutureProvider.family<Feed, RootFeedRequest>(
(ref, request) async {
final repository = ref.watch(feedRepositoryProvider);
return await repository.fetchRootFeed(
request.serverId,
forceRefresh: request.forceRefresh,
);
},
);
/// Request object for fetching feeds
class FeedRequest {
final String serverId;
final String url;
final bool forceRefresh;
const FeedRequest({
required this.serverId,
required this.url,
this.forceRefresh = false,
});
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is FeedRequest &&
runtimeType == other.runtimeType &&
serverId == other.serverId &&
url == other.url &&
forceRefresh == other.forceRefresh;
@override
int get hashCode => serverId.hashCode ^ url.hashCode ^ forceRefresh.hashCode;
}
/// Request object for fetching root feeds
class RootFeedRequest {
final String serverId;
final bool forceRefresh;
const RootFeedRequest({
required this.serverId,
this.forceRefresh = false,
});
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is RootFeedRequest &&
runtimeType == other.runtimeType &&
serverId == other.serverId &&
forceRefresh == other.forceRefresh;
@override
int get hashCode => serverId.hashCode ^ forceRefresh.hashCode;
}