diff --git a/lib/widgets/chat_message_bubble.dart b/lib/widgets/chat_message_bubble.dart index 87e04e8..fe78e3e 100644 --- a/lib/widgets/chat_message_bubble.dart +++ b/lib/widgets/chat_message_bubble.dart @@ -23,8 +23,7 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:open_file/open_file.dart'; import 'package:gwid/full_screen_video_player.dart'; -// Кэш для уже вычисленных цветов -final _userColorCache = {}; + bool _currentIsDark = false; enum MessageReadStatus { @@ -102,16 +101,12 @@ class FileDownloadProgressService { Color _getUserColor(int userId, BuildContext context) { final bool isDark = Theme.of(context).brightness == Brightness.dark; - // Очищаем кэш при смене темы + if (isDark != _currentIsDark) { - _userColorCache.clear(); + _currentIsDark = isDark; } - // Возвращаем из кэша, если уже вычисляли - if (_userColorCache.containsKey(userId)) { - return _userColorCache[userId]!; - } final List materialYouColors = isDark ? [ @@ -166,8 +161,6 @@ Color _getUserColor(int userId, BuildContext context) { final colorIndex = userId % materialYouColors.length; final color = materialYouColors[colorIndex]; - // Сохраняем в кэш - _userColorCache[userId] = color; return color; }