fixing bug of count my shift
This commit is contained in:
@@ -63,6 +63,7 @@ class ShiftsBloc extends Bloc<ShiftsEvent, ShiftsState> {
|
||||
availableLoaded: false,
|
||||
historyLoading: false,
|
||||
historyLoaded: false,
|
||||
myShiftsLoaded: true,
|
||||
searchQuery: '',
|
||||
jobType: 'all',
|
||||
));
|
||||
@@ -83,6 +84,7 @@ class ShiftsBloc extends Bloc<ShiftsEvent, ShiftsState> {
|
||||
try {
|
||||
final historyResult = await getHistoryShifts();
|
||||
emit(currentState.copyWith(
|
||||
myShiftsLoaded: true,
|
||||
historyShifts: historyResult,
|
||||
historyLoading: false,
|
||||
historyLoaded: true,
|
||||
@@ -129,6 +131,7 @@ class ShiftsBloc extends Bloc<ShiftsEvent, ShiftsState> {
|
||||
availableLoaded: false,
|
||||
historyLoading: false,
|
||||
historyLoaded: false,
|
||||
myShiftsLoaded: false,
|
||||
searchQuery: '',
|
||||
jobType: 'all',
|
||||
));
|
||||
@@ -157,6 +160,7 @@ class ShiftsBloc extends Bloc<ShiftsEvent, ShiftsState> {
|
||||
availableLoaded: false,
|
||||
historyLoading: false,
|
||||
historyLoaded: false,
|
||||
myShiftsLoaded: false,
|
||||
searchQuery: '',
|
||||
jobType: 'all',
|
||||
);
|
||||
@@ -184,7 +188,10 @@ class ShiftsBloc extends Bloc<ShiftsEvent, ShiftsState> {
|
||||
|
||||
if (state is ShiftsLoaded) {
|
||||
final currentState = state as ShiftsLoaded;
|
||||
emit(currentState.copyWith(myShifts: myShiftsResult));
|
||||
emit(currentState.copyWith(
|
||||
myShifts: myShiftsResult,
|
||||
myShiftsLoaded: true,
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -198,6 +205,7 @@ class ShiftsBloc extends Bloc<ShiftsEvent, ShiftsState> {
|
||||
availableLoaded: false,
|
||||
historyLoading: false,
|
||||
historyLoaded: false,
|
||||
myShiftsLoaded: true,
|
||||
searchQuery: '',
|
||||
jobType: 'all',
|
||||
));
|
||||
|
||||
@@ -22,6 +22,7 @@ class ShiftsLoaded extends ShiftsState {
|
||||
final bool availableLoaded;
|
||||
final bool historyLoading;
|
||||
final bool historyLoaded;
|
||||
final bool myShiftsLoaded;
|
||||
final String searchQuery;
|
||||
final String jobType;
|
||||
|
||||
@@ -35,6 +36,7 @@ class ShiftsLoaded extends ShiftsState {
|
||||
required this.availableLoaded,
|
||||
required this.historyLoading,
|
||||
required this.historyLoaded,
|
||||
required this.myShiftsLoaded,
|
||||
required this.searchQuery,
|
||||
required this.jobType,
|
||||
});
|
||||
@@ -49,6 +51,7 @@ class ShiftsLoaded extends ShiftsState {
|
||||
bool? availableLoaded,
|
||||
bool? historyLoading,
|
||||
bool? historyLoaded,
|
||||
bool? myShiftsLoaded,
|
||||
String? searchQuery,
|
||||
String? jobType,
|
||||
}) {
|
||||
@@ -62,6 +65,7 @@ class ShiftsLoaded extends ShiftsState {
|
||||
availableLoaded: availableLoaded ?? this.availableLoaded,
|
||||
historyLoading: historyLoading ?? this.historyLoading,
|
||||
historyLoaded: historyLoaded ?? this.historyLoaded,
|
||||
myShiftsLoaded: myShiftsLoaded ?? this.myShiftsLoaded,
|
||||
searchQuery: searchQuery ?? this.searchQuery,
|
||||
jobType: jobType ?? this.jobType,
|
||||
);
|
||||
@@ -78,6 +82,7 @@ class ShiftsLoaded extends ShiftsState {
|
||||
availableLoaded,
|
||||
historyLoading,
|
||||
historyLoaded,
|
||||
myShiftsLoaded,
|
||||
searchQuery,
|
||||
jobType,
|
||||
];
|
||||
|
||||
@@ -98,6 +98,9 @@ class _ShiftsPageState extends State<ShiftsPage> {
|
||||
final bool historyLoaded = (state is ShiftsLoaded)
|
||||
? state.historyLoaded
|
||||
: false;
|
||||
final bool myShiftsLoaded = (state is ShiftsLoaded)
|
||||
? state.myShiftsLoaded
|
||||
: false;
|
||||
final bool blockTabsForFind = _prioritizeFind && !availableLoaded;
|
||||
|
||||
// Note: "filteredJobs" logic moved to FindShiftsTab
|
||||
@@ -137,6 +140,7 @@ class _ShiftsPageState extends State<ShiftsPage> {
|
||||
"My Shifts",
|
||||
UiIcons.calendar,
|
||||
myShifts.length,
|
||||
showCount: myShiftsLoaded,
|
||||
enabled: !blockTabsForFind,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
|
||||
Reference in New Issue
Block a user