prepare for multiple apps
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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:nullability/nullability.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:weblibre/core/logger.dart';
|
||||
|
||||
part 'add_dialog_blocking.g.dart';
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
class AddFeedDialogBlocking extends _$AddFeedDialogBlocking {
|
||||
DateTime? _lastIgnore;
|
||||
final _ignoredUrls = <Uri, DateTime>{};
|
||||
|
||||
void ignore(Uri url) {
|
||||
final date = DateTime.now();
|
||||
|
||||
_lastIgnore = date;
|
||||
_ignoredUrls[url] = date;
|
||||
}
|
||||
|
||||
bool canPush(Uri url) {
|
||||
if (_lastIgnore.mapNotNull(
|
||||
(last) =>
|
||||
DateTime.now().difference(last) <= const Duration(seconds: 30),
|
||||
) ??
|
||||
false) {
|
||||
logger.i('Blocking add feed default timeout for $url');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_ignoredUrls[url].mapNotNull(
|
||||
(last) =>
|
||||
DateTime.now().difference(last) <= const Duration(minutes: 5),
|
||||
) ??
|
||||
false) {
|
||||
logger.i('Blocking add feed url specific for $url');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@override
|
||||
void build() {}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'add_dialog_blocking.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(AddFeedDialogBlocking)
|
||||
final addFeedDialogBlockingProvider = AddFeedDialogBlockingProvider._();
|
||||
|
||||
final class AddFeedDialogBlockingProvider
|
||||
extends $NotifierProvider<AddFeedDialogBlocking, void> {
|
||||
AddFeedDialogBlockingProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
retry: null,
|
||||
name: r'addFeedDialogBlockingProvider',
|
||||
isAutoDispose: false,
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@override
|
||||
String debugGetCreateSourceHash() => _$addFeedDialogBlockingHash();
|
||||
|
||||
@$internal
|
||||
@override
|
||||
AddFeedDialogBlocking create() => AddFeedDialogBlocking();
|
||||
|
||||
/// {@macro riverpod.override_with_value}
|
||||
Override overrideWithValue(void value) {
|
||||
return $ProviderOverride(
|
||||
origin: this,
|
||||
providerOverride: $SyncValueProvider<void>(value),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _$addFeedDialogBlockingHash() =>
|
||||
r'513071d5e507dd292df6b4a3ee3ef7d2217db5bb';
|
||||
|
||||
abstract class _$AddFeedDialogBlocking extends $Notifier<void> {
|
||||
void build();
|
||||
@$mustCallSuper
|
||||
@override
|
||||
void runBuild() {
|
||||
final ref = this.ref as $Ref<void, void>;
|
||||
final element =
|
||||
ref.element
|
||||
as $ClassProviderElement<
|
||||
AnyNotifier<void, void>,
|
||||
void,
|
||||
Object?,
|
||||
Object?
|
||||
>;
|
||||
element.handleCreate(ref, build);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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';
|
||||
|
||||
part 'article_filter.g.dart';
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
class ArticleFilter extends _$ArticleFilter {
|
||||
void addTag(String tagId) {
|
||||
state = {...state, tagId};
|
||||
}
|
||||
|
||||
void removeTag(String tagId) {
|
||||
if (state.isNotEmpty) {
|
||||
state = {...state}..remove(tagId);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Set<String> build() {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'article_filter.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(ArticleFilter)
|
||||
final articleFilterProvider = ArticleFilterProvider._();
|
||||
|
||||
final class ArticleFilterProvider
|
||||
extends $NotifierProvider<ArticleFilter, Set<String>> {
|
||||
ArticleFilterProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
retry: null,
|
||||
name: r'articleFilterProvider',
|
||||
isAutoDispose: false,
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@override
|
||||
String debugGetCreateSourceHash() => _$articleFilterHash();
|
||||
|
||||
@$internal
|
||||
@override
|
||||
ArticleFilter create() => ArticleFilter();
|
||||
|
||||
/// {@macro riverpod.override_with_value}
|
||||
Override overrideWithValue(Set<String> value) {
|
||||
return $ProviderOverride(
|
||||
origin: this,
|
||||
providerOverride: $SyncValueProvider<Set<String>>(value),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _$articleFilterHash() => r'61e4d5230e214038e753bc173158ed1d4dc57040';
|
||||
|
||||
abstract class _$ArticleFilter extends $Notifier<Set<String>> {
|
||||
Set<String> build();
|
||||
@$mustCallSuper
|
||||
@override
|
||||
void runBuild() {
|
||||
final ref = this.ref as $Ref<Set<String>, Set<String>>;
|
||||
final element =
|
||||
ref.element
|
||||
as $ClassProviderElement<
|
||||
AnyNotifier<Set<String>, Set<String>>,
|
||||
Set<String>,
|
||||
Object?,
|
||||
Object?
|
||||
>;
|
||||
element.handleCreate(ref, build);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user