mirror of
https://gitlab.com/mysocialportal/relatica
synced 2024-10-18 13:33:32 +00:00
Fix infinite querying when the user has no notifications or DMs
This commit is contained in:
parent
fd222733f6
commit
18cc85e565
4 changed files with 12 additions and 4 deletions
|
@ -41,8 +41,10 @@ class PagesManager<TResult, TID> {
|
|||
}
|
||||
final result = await onRequest(PagingData(limit: limit));
|
||||
if (result.isSuccess) {
|
||||
final newPage = result.value.map((data) => idMapper(data));
|
||||
_pages.add(newPage);
|
||||
if (result.value.previous != null || result.value.next != null) {
|
||||
final newPage = result.value.map((data) => idMapper(data));
|
||||
_pages.add(newPage);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ class NotificationsScreen extends StatelessWidget {
|
|||
),
|
||||
];
|
||||
if (notifications.isEmpty) {
|
||||
manager.updateNotifications();
|
||||
title = 'Notifications';
|
||||
body = Center(
|
||||
child: Column(
|
||||
|
|
|
@ -14,10 +14,12 @@ import 'auth_service.dart';
|
|||
class DirectMessageService extends ChangeNotifier {
|
||||
static final _logger = Logger('$DirectMessageService');
|
||||
final _threads = <String, DirectMessageThread>{};
|
||||
var _firstLoading = true;
|
||||
|
||||
List<DirectMessageThread> getThreads({bool unreadyOnly = false}) {
|
||||
if (_threads.isEmpty) {
|
||||
if (_threads.isEmpty && _firstLoading) {
|
||||
updateThreads();
|
||||
_firstLoading = false;
|
||||
}
|
||||
|
||||
if (unreadyOnly) {
|
||||
|
|
|
@ -22,8 +22,13 @@ class NotificationsManager extends ChangeNotifier {
|
|||
idMapper: (nn) => nn.map((n) => n.id).toList(),
|
||||
onRequest: _clientGetNotificationsRequest,
|
||||
);
|
||||
var _firstLoad = true;
|
||||
|
||||
List<UserNotification> get notifications {
|
||||
if (_notifications.isEmpty && _firstLoad) {
|
||||
updateNotifications();
|
||||
_firstLoad = false;
|
||||
}
|
||||
final result = List<UserNotification>.from(_notifications.values);
|
||||
result.sort((n1, n2) {
|
||||
if (n1.dismissed == n2.dismissed) {
|
||||
|
|
Loading…
Reference in a new issue