fixing conflict
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// notification_view_model.dart
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:tm_app/core/utils/app_toast.dart';
|
||||
@@ -79,7 +80,8 @@ class NotificationViewModel with ChangeNotifier {
|
||||
}
|
||||
notifyListeners();
|
||||
|
||||
final int offset = (page - 1) * _pageSize;
|
||||
final int offset = page * _pageSize;
|
||||
|
||||
final result = await _repository.getNotifications(
|
||||
limit: _pageSize,
|
||||
offset: offset,
|
||||
@@ -88,10 +90,15 @@ class NotificationViewModel with ChangeNotifier {
|
||||
switch (result) {
|
||||
case Ok<NotificationResponseModel>():
|
||||
final data = result.value;
|
||||
|
||||
if (isPagination && allNotificationResponse != null) {
|
||||
final old = allNotificationResponse?.data ?? [];
|
||||
final fresh = data.data ?? [];
|
||||
allNotificationResponse = data.copyWith(data: [...old, ...fresh]);
|
||||
|
||||
allNotificationResponse = allNotificationResponse!.copyWith(
|
||||
data: [...old, ...fresh],
|
||||
meta: data.meta,
|
||||
);
|
||||
} else {
|
||||
allNotificationResponse = data;
|
||||
}
|
||||
@@ -100,7 +107,7 @@ class NotificationViewModel with ChangeNotifier {
|
||||
|
||||
currentPageAll = page;
|
||||
totalPagesAll = data.meta?.pages ?? 1;
|
||||
hasMoreAll = (data.data?.length ?? 0) >= _pageSize;
|
||||
hasMoreAll = currentPageAll < totalPagesAll;
|
||||
break;
|
||||
|
||||
case Error<NotificationResponseModel>():
|
||||
@@ -124,7 +131,7 @@ class NotificationViewModel with ChangeNotifier {
|
||||
}
|
||||
notifyListeners();
|
||||
|
||||
final int offset = (page - 1) * _pageSize;
|
||||
final int offset = page * _pageSize;
|
||||
final result = await _repository.getUnreadNotifications(
|
||||
limit: _pageSize,
|
||||
offset: offset,
|
||||
@@ -167,9 +174,9 @@ class NotificationViewModel with ChangeNotifier {
|
||||
}
|
||||
notifyListeners();
|
||||
|
||||
final int offset = (page - 1) * _pageSize;
|
||||
final int offset = page * _pageSize;
|
||||
|
||||
final result = await _repository.getUnreadNotifications(
|
||||
final result = await _repository.getImportantNotifications(
|
||||
limit: _pageSize,
|
||||
offset: offset,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user