From 72424bf92cb0f9a90b9b9ae0364a1a45731e5dd9 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Fri, 8 May 2026 15:19:08 +0300 Subject: [PATCH] Update: 2026-05-08 15:19:08 --- musadaq-app/lib/core/utils/logger.dart | 7 +++++-- .../scanner/controllers/scanner_controller.dart | 10 ++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/musadaq-app/lib/core/utils/logger.dart b/musadaq-app/lib/core/utils/logger.dart index 35ed907..ad245bd 100644 --- a/musadaq-app/lib/core/utils/logger.dart +++ b/musadaq-app/lib/core/utils/logger.dart @@ -2,16 +2,19 @@ import 'dart:developer' as developer; import 'package:flutter/foundation.dart'; class AppLogger { + /// Master toggle for logging. Set to false to disable all logs. + static bool isLoggingEnabled = kDebugMode; + /// Custom print function that only logs in debug mode. static void print(String message, {String name = 'Musadaq'}) { - if (kDebugMode) { + if (isLoggingEnabled) { developer.log(message, name: name); } } /// Custom error logger static void error(String message, [dynamic error, StackTrace? stackTrace]) { - if (kDebugMode) { + if (isLoggingEnabled) { developer.log(message, name: 'Musadaq_Error', error: error, stackTrace: stackTrace); } } diff --git a/musadaq-app/lib/features/scanner/controllers/scanner_controller.dart b/musadaq-app/lib/features/scanner/controllers/scanner_controller.dart index 5fc80dc..c189deb 100644 --- a/musadaq-app/lib/features/scanner/controllers/scanner_controller.dart +++ b/musadaq-app/lib/features/scanner/controllers/scanner_controller.dart @@ -170,8 +170,15 @@ class ScannerController extends GetxController { } void _startPolling(String batchId) { - // Check status every 2 seconds + bool firstPoll = true; + + // Check status periodically Future.doWhile(() async { + // Wait before checking + // First poll is after 8 seconds (AI takes time), subsequent are 5 seconds + await Future.delayed(Duration(seconds: firstPoll ? 8 : 5)); + firstPoll = false; + // If we are no longer interested in this batch or it's done, stop polling if (currentBatchId.value != batchId || isBatchDone.value) return false; @@ -204,7 +211,6 @@ class ScannerController extends GetxController { AppLogger.error('Polling error', e); } - await Future.delayed(const Duration(seconds: 2)); return true; // Continue polling }); }