Removed the 5 min dialogue
This commit is contained in:
@@ -188,11 +188,6 @@ class HomeViewModel @Inject constructor(
|
|||||||
val attendanceDoc = getAttendanceDocument(userId, currentDate)
|
val attendanceDoc = getAttendanceDocument(userId, currentDate)
|
||||||
|
|
||||||
if (attendanceDoc?.exists() == true) {
|
if (attendanceDoc?.exists() == true) {
|
||||||
val checkIn = attendanceDoc.getString("checkIn1") // Using first check-in for time validation
|
|
||||||
if (checkIn != null && !isTimeDifferenceGreaterThanMinutes(givenTimeStr = checkIn, minutes = 0L)) {
|
|
||||||
handleError("Wait 5 minutes before logging off")
|
|
||||||
return@launch
|
|
||||||
}
|
|
||||||
handleExistingAttendance(attendanceDoc)
|
handleExistingAttendance(attendanceDoc)
|
||||||
} else {
|
} else {
|
||||||
handleNewAttendance(userId, currentDate)
|
handleNewAttendance(userId, currentDate)
|
||||||
@@ -278,16 +273,16 @@ class HomeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isTimeDifferenceGreaterThanMinutes(givenTimeStr: String, currentTimeStr: String = formatTimestamp(Timestamp.now()), minutes: Long): Boolean {
|
// private fun isTimeDifferenceGreaterThanMinutes(givenTimeStr: String, currentTimeStr: String = formatTimestamp(Timestamp.now()), minutes: Long): Boolean {
|
||||||
val formatter = DateTimeFormatter.ofPattern("dd MMMM yyyy hh:mm:ss a")
|
// val formatter = DateTimeFormatter.ofPattern("dd MMMM yyyy hh:mm:ss a")
|
||||||
|
//
|
||||||
val givenTime = LocalDateTime.parse(givenTimeStr, formatter)
|
// val givenTime = LocalDateTime.parse(givenTimeStr, formatter)
|
||||||
val currentTime = LocalDateTime.parse(currentTimeStr, formatter)
|
// val currentTime = LocalDateTime.parse(currentTimeStr, formatter)
|
||||||
|
//
|
||||||
val timeDifference = abs(ChronoUnit.MINUTES.between(givenTime, currentTime))
|
// val timeDifference = abs(ChronoUnit.MINUTES.between(givenTime, currentTime))
|
||||||
|
//
|
||||||
return timeDifference > minutes
|
// return timeDifference > minutes
|
||||||
}
|
// }
|
||||||
|
|
||||||
private suspend fun handleNewAttendance(userId: String, currentDate: String) {
|
private suspend fun handleNewAttendance(userId: String, currentDate: String) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user