prepare for multiple apps

This commit is contained in:
Fabian Freund
2026-04-06 12:23:11 +02:00
parent bd1600e8dc
commit 5afc323f04
904 changed files with 29 additions and 29 deletions
@@ -0,0 +1,73 @@
/*
* Copyright (c) 2024-2026 Fabian Freund.
*
* This file is part of WebLibre
* (see https://weblibre.eu).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:weblibre/core/logger.dart';
import 'package:weblibre/features/web_feed/domain/repositories/feed_repository.dart';
import 'package:weblibre/features/web_feed/domain/services/feed_reader.dart';
part 'fetch_articles.g.dart';
@Riverpod(keepAlive: true)
class FetchArticlesController extends _$FetchArticlesController {
Future<void> fetchAllArticles() async {
state = const AsyncLoading();
state = await AsyncValue.guard(() async {
final feedRepository = ref.read(feedRepositoryProvider.notifier);
final feeds = await feedRepository.getAllFeeds();
await Future.wait(
feeds.map((feed) async {
try {
final feedReader = ref.read(feedReaderProvider.notifier);
final result = await feedReader.parseFeed(feed.url);
await feedRepository.upsertArticles(result.articleData);
await feedRepository.touchFeedFetched(feed.url);
} catch (e, s) {
logger.e(
'Failed fetching feed ${feed.url}',
error: e,
stackTrace: s,
);
}
}).toList(),
);
});
}
Future<void> fetchFeedArticles(Uri uri) async {
state = const AsyncLoading();
state = await AsyncValue.guard(() async {
final feedRepository = ref.read(feedRepositoryProvider.notifier);
final result = await ref.read(feedReaderProvider.notifier).parseFeed(uri);
await feedRepository.upsertArticles(result.articleData);
await feedRepository.touchFeedFetched(uri);
});
}
@override
AsyncValue<void> build() {
return const AsyncData(null);
}
}
@@ -0,0 +1,63 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'fetch_articles.dart';
// **************************************************************************
// RiverpodGenerator
// **************************************************************************
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint, type=warning
@ProviderFor(FetchArticlesController)
final fetchArticlesControllerProvider = FetchArticlesControllerProvider._();
final class FetchArticlesControllerProvider
extends $NotifierProvider<FetchArticlesController, AsyncValue<void>> {
FetchArticlesControllerProvider._()
: super(
from: null,
argument: null,
retry: null,
name: r'fetchArticlesControllerProvider',
isAutoDispose: false,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$fetchArticlesControllerHash();
@$internal
@override
FetchArticlesController create() => FetchArticlesController();
/// {@macro riverpod.override_with_value}
Override overrideWithValue(AsyncValue<void> value) {
return $ProviderOverride(
origin: this,
providerOverride: $SyncValueProvider<AsyncValue<void>>(value),
);
}
}
String _$fetchArticlesControllerHash() =>
r'5dcb9de003bc911d365c6a8ef107bf1bf446755b';
abstract class _$FetchArticlesController extends $Notifier<AsyncValue<void>> {
AsyncValue<void> build();
@$mustCallSuper
@override
void runBuild() {
final ref = this.ref as $Ref<AsyncValue<void>, AsyncValue<void>>;
final element =
ref.element
as $ClassProviderElement<
AnyNotifier<AsyncValue<void>, AsyncValue<void>>,
AsyncValue<void>,
Object?,
Object?
>;
element.handleCreate(ref, build);
}
}