update news

This commit is contained in:
Phuoc Nguyen
2025-11-10 15:37:55 +07:00
parent 36bdf6613b
commit 67fd5ed142
17 changed files with 1016 additions and 211 deletions

View File

@@ -12,17 +12,17 @@ import 'package:worker/features/news/domain/repositories/news_repository.dart';
/// News Repository Implementation
class NewsRepositoryImpl implements NewsRepository {
/// Local data source
final NewsLocalDataSource localDataSource;
/// Remote data source
final NewsRemoteDataSource remoteDataSource;
/// Constructor
NewsRepositoryImpl({
required this.localDataSource,
required this.remoteDataSource,
});
/// Local data source
final NewsLocalDataSource localDataSource;
/// Remote data source
final NewsRemoteDataSource remoteDataSource;
@override
Future<List<BlogCategory>> getBlogCategories() async {
@@ -98,6 +98,20 @@ class NewsRepositoryImpl implements NewsRepository {
}
}
@override
Future<NewsArticle?> getArticleByIdFromApi(String articleId) async {
try {
// Fetch blog post detail from Frappe API using frappe.client.get
final blogPostModel = await remoteDataSource.getBlogPostDetail(articleId);
// Convert to domain entity
return blogPostModel.toEntity();
} catch (e) {
print('[NewsRepository] Error getting article by id from API: $e');
rethrow; // Re-throw to let providers handle the error
}
}
@override
Future<List<NewsArticle>> refreshArticles() async {
try {