Validate stale chat requests, show info instead of auto-dismiss
- Add validateIncomingRequest() — checks session status with backend - Home screen validates before showing sheet (on resume + listener) - IncomingRequestSheet shows "cancelled/accepted by other" message instead of silently dismissing when request becomes stale Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -130,6 +130,22 @@ class ChatRequest extends _$ChatRequest {
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if the current incoming request is still valid (pending_acceptance).
|
||||
/// If stale, reset to listening state.
|
||||
Future<void> validateIncomingRequest() async {
|
||||
if (state is! ChatRequestIncomingData) return;
|
||||
final sessionId = (state as ChatRequestIncomingData).sessionId;
|
||||
try {
|
||||
final response = await _apiClient.get('/api/shared/chat/$sessionId/info');
|
||||
final status = response['data']?['status'] as String?;
|
||||
if (status != 'pending_acceptance') {
|
||||
state = const ChatRequestListeningData();
|
||||
}
|
||||
} catch (_) {
|
||||
state = const ChatRequestListeningData();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> accept(String sessionId) async {
|
||||
state = const ChatRequestAcceptingData();
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user