Fixed loading bug in notification mobile
This commit is contained in:
@@ -39,9 +39,16 @@ class NotificationViewModel with ChangeNotifier {
|
||||
_unreadNotificationResponse;
|
||||
bool get isUnreadLoading => _isUnreadLoading;
|
||||
|
||||
bool _isMoreLoading = false;
|
||||
bool get isMoreLoading => _isMoreLoading;
|
||||
|
||||
/// Fetch notifications
|
||||
Future<void> getNotifications({int page = 1, bool isMobile = false}) async {
|
||||
_isLoading = true;
|
||||
if (isMobile && page > 1) {
|
||||
_isMoreLoading = true; // 👈 لودینگ فقط برای پیج بعدی
|
||||
} else {
|
||||
_isLoading = true; // 👈 لودینگ عادی (اولین بار یا رفرش)
|
||||
}
|
||||
notifyListeners();
|
||||
|
||||
final int offset = _pageSize * page;
|
||||
@@ -80,6 +87,7 @@ class NotificationViewModel with ChangeNotifier {
|
||||
}
|
||||
|
||||
_isLoading = false;
|
||||
_isMoreLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -107,7 +115,9 @@ class NotificationViewModel with ChangeNotifier {
|
||||
case Ok<Map<String, dynamic>>():
|
||||
final response = result.value;
|
||||
final success = response['success'] as bool? ?? false;
|
||||
final message = response['message'] as String? ?? NotificationStrings.unknownResponse;
|
||||
final message =
|
||||
response['message'] as String? ??
|
||||
NotificationStrings.unknownResponse;
|
||||
|
||||
if (success) {
|
||||
if (_notificationResponseModel?.data?.notifications != null) {
|
||||
|
||||
Reference in New Issue
Block a user