From 2095170e70972fb8b1eb7858d56dbef3ce56a8f4 Mon Sep 17 00:00:00 2001 From: klockky Date: Thu, 14 May 2026 14:41:52 +0300 Subject: [PATCH] =?UTF-8?q?perf:=20=D0=BA=D1=8D=D1=88=20=D0=B4=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=B2=D0=B0=20=D0=B2=D0=BA=D0=BB=D0=B0=D0=B4=D0=BA=D0=B8?= =?UTF-8?q?=20=D1=87=D0=B0=D1=82=D0=BE=D0=B2=20=D0=BC=D0=B5=D0=B6=D0=B4?= =?UTF-8?q?=D1=83=20=D1=80=D0=B5=D0=B1=D0=B8=D0=BB=D0=B4=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../screens/chats/chat_list_screen.dart | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/lib/frontend/screens/chats/chat_list_screen.dart b/lib/frontend/screens/chats/chat_list_screen.dart index a2ffb88..bb9d2fa 100644 --- a/lib/frontend/screens/chats/chat_list_screen.dart +++ b/lib/frontend/screens/chats/chat_list_screen.dart @@ -107,6 +107,37 @@ class _ChatListScreenState extends State StreamSubscription? _stateSub; StreamSubscription? _loginSub; + Widget? _cachedChatsBody; + Object? _chatsBodyCacheKey; + + /// Возвращает дерево вкладки «Чаты», кэшируя его между ребилдами + /// родителя. Тап/драг навбара и FAB не трогают эти state-vars, + /// поэтому ключ остаётся прежним и subtree не пересобирается. + Widget _getChatsBody() { + final key = Object.hashAll([ + identityHashCode(_chats), + identityHashCode(_folders), + _selectedFolderId, + _isInitialLoading, + _foldersListKnown, + _showCacheWarning, + _isSelectionMode, + _shouldCollapseSearch, + _selectedChats.length, + _pullRatio, + _storiesDockedOpen, + _storiesAnimClosing, + _storiesOverscrollRevealArmed, + _sessionState, + identityHashCode(_profile), + ]); + if (_cachedChatsBody == null || _chatsBodyCacheKey != key) { + _chatsBodyCacheKey = key; + _cachedChatsBody = _buildChatsTabBody(); + } + return _cachedChatsBody!; + } + void _toggleSelection(String chatId) { setState(() { if (_selectedChats.contains(chatId)) { @@ -1406,7 +1437,7 @@ class _ChatListScreenState extends State child: SizedBox( width: pageW, height: pageH, - child: _buildChatsTabBody(), + child: _getChatsBody(), ), ), RepaintBoundary(