Merge branch 'origin/dev' into feature/session-persistence-new

This commit is contained in:
2026-03-20 12:44:25 +05:30
162 changed files with 6978 additions and 1283 deletions

View File

@@ -229,12 +229,20 @@ class ClockInBloc extends Bloc<ClockInEvent, ClockInState>
event: event,
activeShiftId: newStatus.activeShiftId,
);
} on AppException catch (_) {
// The clock-in API call failed. Re-fetch attendance status to
// reconcile: if the worker is already clocked in (e.g. duplicate
// session from Postgres constraint 23505), treat it as success.
} on AppException catch (e) {
// The backend returns 409 ALREADY_CLOCKED_IN when the worker has
// an active attendance session. This is a normal idempotency
// signal — re-fetch the authoritative status and emit success
// without surfacing an error snackbar.
final bool isAlreadyClockedIn =
e is ApiException && e.apiCode == 'ALREADY_CLOCKED_IN';
// Re-fetch attendance status to reconcile local state with
// the backend (handles both ALREADY_CLOCKED_IN and legacy
// Postgres constraint 23505 duplicates).
final AttendanceStatus currentStatus = await _getAttendanceStatus();
if (currentStatus.isClockedIn) {
if (isAlreadyClockedIn || currentStatus.isClockedIn) {
emit(state.copyWith(
status: ClockInStatus.success,
attendance: currentStatus,