Skip to content

Commit

Permalink
Fix empty leave screen
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-pratik-k committed Aug 3, 2023
1 parent 1d0fd2c commit 61176fc
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/data/model/pagination/pagination.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:equatable/equatable.dart';
import '../leave/leave.dart';

class PaginatedLeaves extends Equatable {
final DocumentSnapshot<Leave> lastDoc;
final DocumentSnapshot<Leave>? lastDoc;
final List<Leave> leaves;

const PaginatedLeaves({required this.leaves, required this.lastDoc});
Expand Down
2 changes: 1 addition & 1 deletion lib/data/repo/leave_repo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class LeaveRepo {
Future<PaginatedLeaves> leaves(
{DocumentSnapshot<Leave>? lastDoc, String? uid}) async =>
await _leaveService.leaves(
limit: 5,
limit: 8,
uid: uid,
lastDoc: lastDoc,
spaceId: _userStateNotifier.currentSpaceId!,
Expand Down
2 changes: 1 addition & 1 deletion lib/data/services/leave_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class LeaveService {

return PaginatedLeaves(
leaves: leavesDoc.docs.map((e) => e.data()).toList(),
lastDoc: leavesDoc.docs.isNotEmpty ? leavesDoc.docs.last : lastDoc!);
lastDoc: leavesDoc.docs.isNotEmpty ? leavesDoc.docs.last : null);
}

Stream<List<Leave>> monthlyLeaveByStartDate(
Expand Down
5 changes: 3 additions & 2 deletions lib/ui/admin/leaves/leave_screen/bloc /admin_leaves_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class AdminLeavesBloc extends Bloc<AdminLeavesEvents, AdminLeavesState> {
InitialAdminLeavesEvent event, Emitter<AdminLeavesState> emit) async {
try {
_members = _employeeRepo.allEmployees.toList();
emit(state.copyWith(members: _members, membersFetchStatus: Status.success));
emit(state.copyWith(
members: _members, membersFetchStatus: Status.success));
add(FetchLeavesInitialEvent());
} on Exception {
emit(state.copyWith(
Expand Down Expand Up @@ -72,7 +73,7 @@ class AdminLeavesBloc extends Bloc<AdminLeavesEvents, AdminLeavesState> {
try {
final paginatedData = await _leaveRepo.leaves(
lastDoc: _lastDoc, uid: state.selectedMember?.uid);
if (paginatedData.lastDoc == _lastDoc) {
if (paginatedData.lastDoc == null) {
_isLoadedMax = true;
}
_lastDoc = paginatedData.lastDoc;
Expand Down

0 comments on commit 61176fc

Please sign in to comment.