From 9480a2a8579e986a4a4af2931e1e73b19e709fb7 Mon Sep 17 00:00:00 2001 From: lotusprey <35681808+lotusprey@users.noreply.github.com> Date: Tue, 24 Sep 2024 22:40:09 +0300 Subject: [PATCH] v.1.5.3 (#170) --- .../android/en-US/changelogs/{76.txt => 77.txt} | 0 lib/feature/activity/activities_provider.dart | 12 ++++++++---- lib/util/graphql.dart | 5 ++--- lib/util/persistence.dart | 2 +- pubspec.yaml | 2 +- 5 files changed, 12 insertions(+), 9 deletions(-) rename fastlane/metadata/android/en-US/changelogs/{76.txt => 77.txt} (100%) diff --git a/fastlane/metadata/android/en-US/changelogs/76.txt b/fastlane/metadata/android/en-US/changelogs/77.txt similarity index 100% rename from fastlane/metadata/android/en-US/changelogs/76.txt rename to fastlane/metadata/android/en-US/changelogs/77.txt diff --git a/lib/feature/activity/activities_provider.dart b/lib/feature/activity/activities_provider.dart index 8c6b77c1..bf236b31 100644 --- a/lib/feature/activity/activities_provider.dart +++ b/lib/feature/activity/activities_provider.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:otraku/extension/date_time_extension.dart'; import 'package:otraku/extension/future_extension.dart'; import 'package:otraku/feature/activity/activities_filter_model.dart'; import 'package:otraku/feature/activity/activities_filter_provider.dart'; @@ -20,7 +19,9 @@ class ActivitiesNotifier extends AutoDisposeFamilyAsyncNotifier, int> { late int viewerId; late ActivitiesFilter filter; - int _lastCreatedAt = DateTime.now().secondsSinceEpoch; + + // Used to skip activities when fetching outdated pages. + int? _lastId; @override FutureOr> build(arg) async { @@ -28,6 +29,7 @@ class ActivitiesNotifier ref.keepAlive(); } + _lastId = null; viewerId = Persistence().id!; filter = ref.watch(activitiesFilterProvider(arg)); return await _fetch(const Paged()); @@ -46,10 +48,10 @@ class ActivitiesNotifier 'typeIn': filter.typeIn.map((t) => t.name).toList(), ...switch (filter) { HomeActivitiesFilter filter => { + 'page': oldState.next, 'isFollowing': filter.onFollowing, if (!filter.withViewerActivities) 'userIdNot': viewerId, if (!filter.onFollowing) 'hasRepliesOrText': true, - if (oldState.items.isNotEmpty) 'createdBefore': _lastCreatedAt, }, UserActivitiesFilter filter => { 'userId': filter.userId, @@ -61,12 +63,14 @@ class ActivitiesNotifier final items = []; for (final a in data['Page']['activities']) { + if (_lastId != null && a['id'] >= _lastId) continue; + final item = Activity.maybe(a, viewerId, Persistence().imageQuality); if (item != null) items.add(item); } if (data['Page']['activities'].isNotEmpty) { - _lastCreatedAt = data['Page']['activities'].last['createdAt']; + _lastId = data['Page']['activities'].last['id']; } return oldState.withNext( diff --git a/lib/util/graphql.dart b/lib/util/graphql.dart index 23e16f11..f49f8ff6 100644 --- a/lib/util/graphql.dart +++ b/lib/util/graphql.dart @@ -539,12 +539,11 @@ abstract class GqlQuery { static const activityPage = r''' query Activities($userId: Int, $userIdNot: Int, $page: Int = 1, $isFollowing: Boolean, - $hasRepliesOrText: Boolean, $typeIn: [ActivityType], $createdBefore: Int) { + $hasRepliesOrText: Boolean, $typeIn: [ActivityType]) { Page(page: $page) { pageInfo {hasNextPage} activities(userId: $userId, userId_not: $userIdNot, isFollowing: $isFollowing, - hasRepliesOrTypeText: $hasRepliesOrText, type_in: $typeIn, sort: [PINNED, ID_DESC], - createdAt_lesser: $createdBefore) { + hasRepliesOrTypeText: $hasRepliesOrText, type_in: $typeIn, sort: [PINNED, ID_DESC]) { ... on TextActivity {...textActivity} ... on ListActivity {...listActivity} ... on MessageActivity {...messageActivity} diff --git a/lib/util/persistence.dart b/lib/util/persistence.dart index f9ceb0f7..a722607c 100644 --- a/lib/util/persistence.dart +++ b/lib/util/persistence.dart @@ -10,7 +10,7 @@ import 'package:otraku/util/theming.dart'; import 'package:path_provider/path_provider.dart'; /// Current app version. -const versionCode = '1.5.2'; +const versionCode = '1.5.3'; /// General options keys. enum _OptionKey { diff --git a/pubspec.yaml b/pubspec.yaml index 344a5260..101ed563 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: An unofficial AniList app. publish_to: 'none' -version: 1.5.2+76 +version: 1.5.3+77 environment: sdk: '>=3.0.0 <4.0.0'