fixing conflict

This commit is contained in:
amirrezaghabeli
2025-09-28 07:23:25 +03:30
parent 26a29003d9
commit fd19e8c66c
9 changed files with 92 additions and 77 deletions
+13 -6
View File
@@ -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,
);