diff --git a/lib/home/app_provider.dart b/lib/home/app_provider.dart index 6250047..c925381 100644 --- a/lib/home/app_provider.dart +++ b/lib/home/app_provider.dart @@ -382,26 +382,31 @@ class AppProvider extends ChangeNotifier { if (isQueuePatients.isNotEmpty) { log("i am here on line 375"); final length = isQueuePatients.length; - for (int i = 0; i < length; i++) { - await Future.delayed(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec)).whenComplete(() async { - PatientTicketModel temp = PatientTicketModel(); - if (patientTickets.isNotEmpty) { - temp = patientTickets.elementAt(0); - patientTickets.removeAt(0); - } - notifyListeners(); + // for (int i = 0; i < length; i++) { + await Future.delayed(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec)).whenComplete(() async { + PatientTicketModel temp = PatientTicketModel(); + if (patientTickets.isNotEmpty && isQueuePatients.length > 1) { + temp = patientTickets.elementAt(0); + patientTickets.removeAt(0); + } + notifyListeners(); + if (isQueuePatients.isNotEmpty) { isQueuePatients.removeAt(0); + } + if (patientTickets.isNotEmpty && isQueuePatients.length > 1) { patientTickets.add(temp); - notifyListeners(); - await voiceCallPatientTicket(patientTickets.first, "listenAudioPlayerEvents"); - updatePatientTicket(patientTickets.first); - }); - } + } + notifyListeners(); + await voiceCallPatientTicket(patientTickets.first, "listenAudioPlayerEvents"); + updatePatientTicket(patientTickets.first); + }); + // } } - isCallingInProgress = false; - log("Setting isCallingInProgress : $isCallingInProgress"); - - if (isApiCallNeeded) { + if (isQueuePatients.isEmpty) { + isCallingInProgress = false; + } + if (isApiCallNeeded && isQueuePatients.isEmpty) { + log("Setting isCallingInProgress : $isCallingInProgress"); Timer(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec), () async { await callPatientsAPI(); isApiCallNeeded = false; @@ -439,10 +444,10 @@ class AppProvider extends ChangeNotifier { // } } - //[OBG M-29, OBG W-E-8, OBG W-I-10, OBG U-33, OBG H-25, OBG H-29, OBG M-37, OBG H-31, OBG H-27, OBG W-P-1, OBG P-25, OBG E-13, OBG P-23, OBG U-21, OBG M-25, OBG W-J-3, OBG V-25, OBG W-D-5, OBG W-G-3, OBG L-63, OBG W-L-2, OBG H-5, OBG G-17, OBG S-19, OBG S-17, OBG S-21, OBG C-39, OBG J-19, OBG G-19, OBG G-15, OBG W-N-9, OBG N-39, OBG H-21, OBG C-37, OBG W-J-1, OBG W-T-2] - - if (isApiCallNeeded && isQueuePatients.isEmpty) { + if (isQueuePatients.isEmpty) { isCallingInProgress = false; + } + if (isApiCallNeeded && isQueuePatients.isEmpty) { log("Setting isCallingInProgress : $isCallingInProgress"); Timer(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec), () async { await callPatientsAPI();