Sync update: 2026-06-20 16:53:51
This commit is contained in:
@@ -129,20 +129,36 @@ class ConversationsScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildConnecting(BuildContext context) => Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CircularProgressIndicator(color: AppTheme.primary),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Connecting to server...',
|
||||
style:
|
||||
TextStyle(color: AppTheme.textSecondary(context)),
|
||||
Widget _buildConnecting(BuildContext context) {
|
||||
final svc = Get.find<WhatsAppService>();
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CircularProgressIndicator(color: AppTheme.primary),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Connecting to server...',
|
||||
style: TextStyle(color: AppTheme.textSecondary(context)),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
svc.status.value = WsStatus.disconnected;
|
||||
svc.connect();
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppTheme.primary,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
child: const Text(
|
||||
'Retry Now',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildError(
|
||||
BuildContext context, ConversationsController ctrl) =>
|
||||
|
||||
@@ -182,12 +182,14 @@ class WhatsAppService extends GetxService {
|
||||
|
||||
void _scheduleReconnect() {
|
||||
_reconnectTimer?.cancel();
|
||||
if (_reconnectCount >= AppConfig.maxReconnectAttempts) {
|
||||
print('[WS] Max reconnect attempts reached');
|
||||
return;
|
||||
}
|
||||
_reconnectCount++;
|
||||
_reconnectTimer = Timer(AppConfig.reconnectDelay, connect);
|
||||
|
||||
// Progressive backoff: starting at reconnectDelay (3s) up to 15s maximum
|
||||
final delaySec = (AppConfig.reconnectDelay.inSeconds * (_reconnectCount > 5 ? 5 : _reconnectCount)).clamp(3, 15);
|
||||
final delay = Duration(seconds: delaySec);
|
||||
|
||||
print('[WS] Reconnecting in ${delay.inSeconds} seconds (attempt $_reconnectCount)...');
|
||||
_reconnectTimer = Timer(delay, connect);
|
||||
}
|
||||
|
||||
// ── Request/Response ─────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user