From ba93e7b514214afc3670581001cf643d99ac0752 Mon Sep 17 00:00:00 2001 From: dab246 Date: Mon, 23 Dec 2024 15:11:57 +0700 Subject: [PATCH] TF-3334 Dispose web socket when close controller --- .../presentation/websocket/web_socket_queue_handler.dart | 3 +++ .../search/email/presentation/search_email_controller.dart | 1 + lib/features/thread/presentation/thread_controller.dart | 1 + 3 files changed, 5 insertions(+) diff --git a/lib/features/push_notification/presentation/websocket/web_socket_queue_handler.dart b/lib/features/push_notification/presentation/websocket/web_socket_queue_handler.dart index 155b0deb6..455473983 100644 --- a/lib/features/push_notification/presentation/websocket/web_socket_queue_handler.dart +++ b/lib/features/push_notification/presentation/websocket/web_socket_queue_handler.dart @@ -116,6 +116,9 @@ class WebSocketQueueHandler { bool isMessageProcessed(String messageId) => _processedMessageIds.contains(messageId); void dispose() { + _messageQueue.clear(); + _processedMessageIds.clear(); _queueController.close(); + _processingLock = null; } } diff --git a/lib/features/search/email/presentation/search_email_controller.dart b/lib/features/search/email/presentation/search_email_controller.dart index 37c9081eb..2bed6ef89 100644 --- a/lib/features/search/email/presentation/search_email_controller.dart +++ b/lib/features/search/email/presentation/search_email_controller.dart @@ -1030,6 +1030,7 @@ class SearchEmailController extends BaseController _deBouncerTime.cancel(); emailUIActionWorker.dispose(); dashBoardActionWorker.dispose(); + _webSocketQueueHandler?.dispose(); super.onClose(); } } \ No newline at end of file diff --git a/lib/features/thread/presentation/thread_controller.dart b/lib/features/thread/presentation/thread_controller.dart index c23994fcd..f3d2fa672 100644 --- a/lib/features/thread/presentation/thread_controller.dart +++ b/lib/features/thread/presentation/thread_controller.dart @@ -149,6 +149,7 @@ class ThreadController extends BaseController with EmailActionController { if (PlatformInfo.isWeb) { _resizeBrowserStreamSubscription?.cancel(); } + _webSocketQueueHandler?.dispose(); super.onClose(); }