Data loading adjustments

This commit is contained in:
franzap
2024-10-24 01:02:47 -03:00
parent f8b18d0cae
commit 7e4c1b4df0
2 changed files with 6 additions and 9 deletions
+2 -2
View File
@@ -124,8 +124,9 @@ mixin NostrAdapter<T extends DataModelMixin<T>> on Adapter<T> {
kinds: {kind, ...?additionalKinds},
tags: params,
limit: limit,
since: since,
until: until,
// Disable since when until is present
since: until != null ? null : since,
);
final result = await relay.queryRaw(req);
@@ -170,7 +171,6 @@ mixin NostrAdapter<T extends DataModelMixin<T>> on Adapter<T> {
class RelayListenerNotifier extends Notifier<void> {
@override
void build() {
fetch();
final timer = Timer.periodic(Duration(minutes: 30), (_) => fetch());
// This will get disposed when clearing and restarting the app
+4 -7
View File
@@ -88,17 +88,13 @@ class LatestReleasesAppNotifier extends StateNotifier<AsyncValue<List<App>>> {
int _page = 1;
final Ref ref;
LatestReleasesAppNotifier(this.ref) : super(AsyncLoading());
LatestReleasesAppNotifier(this.ref) : super(AsyncLoading()) {
fetch();
}
Future<void> fetch({bool next = false}) async {
if (next) {
_page++;
} else {
final apps = _fetchLocal();
if (apps.isNotEmpty) {
state = AsyncData(apps);
return;
}
}
// Can't use ignoreReturn, as super.findAll does use the result
@@ -107,6 +103,7 @@ class LatestReleasesAppNotifier extends StateNotifier<AsyncValue<List<App>>> {
'includes': true,
'limit': 10,
'until': next ? _oldestCreatedAt : null,
'since': null,
},
);