refactor: remove excessive logging and improve code clarity in various components
This commit is contained in:
@@ -630,9 +630,7 @@ if (message.id in currentIds) {
|
||||
withContext(Dispatchers.Main.immediate) {
|
||||
val dbIds = messages.map { it.id }.toSet()
|
||||
val currentMsgs = _messages.value
|
||||
android.util.Log.d("ChatViewModel", " Current ids: ${currentMsgs.map { it.id }.take(5)}...")
|
||||
|
||||
val optimisticMessages = currentMsgs.filter { msg ->
|
||||
val optimisticMessages = currentMsgs.filter { msg ->
|
||||
msg.status == MessageStatus.SENDING && msg.id !in dbIds
|
||||
}
|
||||
val newList = messages + optimisticMessages
|
||||
|
||||
@@ -253,20 +253,15 @@ fun ChatsListScreen(
|
||||
LaunchedEffect(accountPublicKey, accountPrivateKey) {
|
||||
if (accountPublicKey.isNotEmpty() && accountPrivateKey.isNotEmpty()) {
|
||||
val launchStart = System.currentTimeMillis()
|
||||
android.util.Log.d("ChatsListScreen", "🚀 LaunchedEffect started")
|
||||
|
||||
chatsViewModel.setAccount(accountPublicKey, accountPrivateKey)
|
||||
android.util.Log.d("ChatsListScreen", "📋 setAccount took ${System.currentTimeMillis() - launchStart}ms")
|
||||
|
||||
// Устанавливаем аккаунт для RecentSearchesManager
|
||||
// Устанавливаем аккаунт для RecentSearchesManager
|
||||
RecentSearchesManager.setAccount(accountPublicKey)
|
||||
|
||||
// 🔥 КРИТИЧНО: Инициализируем MessageRepository для обработки входящих
|
||||
// сообщений
|
||||
val initStart = System.currentTimeMillis()
|
||||
ProtocolManager.initializeAccount(accountPublicKey, accountPrivateKey)
|
||||
android.util.Log.d("ChatsListScreen", "🌐 initializeAccount took ${System.currentTimeMillis() - initStart}ms")
|
||||
android.util.Log.d("ChatsListScreen", "✅ Total LaunchedEffect: ${System.currentTimeMillis() - launchStart}ms")
|
||||
android.util.Log.d("ChatsListScreen", "✅ Total LaunchedEffect: ${System.currentTimeMillis() - launchStart}ms")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -112,10 +112,7 @@ class ChatsListViewModel(application: Application) : AndroidViewModel(applicatio
|
||||
*/
|
||||
fun setAccount(publicKey: String, privateKey: String) {
|
||||
val setAccountStart = System.currentTimeMillis()
|
||||
android.util.Log.d(TAG, "📋 setAccount called for: ${publicKey.take(8)}...")
|
||||
|
||||
if (currentAccount == publicKey) {
|
||||
android.util.Log.d(TAG, "📋 Account already set, skipping")
|
||||
if (currentAccount == publicKey) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -124,16 +121,12 @@ class ChatsListViewModel(application: Application) : AndroidViewModel(applicatio
|
||||
|
||||
currentAccount = publicKey
|
||||
currentPrivateKey = privateKey
|
||||
|
||||
android.util.Log.d(TAG, "📋 Starting dialogs subscription...")
|
||||
|
||||
// Подписываемся на обычные диалоги
|
||||
viewModelScope.launch {
|
||||
dialogDao.getDialogsFlow(publicKey)
|
||||
.flowOn(Dispatchers.IO) // 🚀 Flow работает на IO
|
||||
.map { dialogsList ->
|
||||
val mapStart = System.currentTimeMillis()
|
||||
android.util.Log.d(TAG, "🔄 Processing ${dialogsList.size} dialogs...")
|
||||
// <20> ОПТИМИЗАЦИЯ: Параллельная расшифровка всех сообщений
|
||||
withContext(Dispatchers.Default) {
|
||||
dialogsList.map { dialog ->
|
||||
@@ -207,12 +200,10 @@ class ChatsListViewModel(application: Application) : AndroidViewModel(applicatio
|
||||
}.awaitAll()
|
||||
}.also {
|
||||
val mapTime = System.currentTimeMillis() - mapStart
|
||||
android.util.Log.d(TAG, "🔄 Dialogs processed in ${mapTime}ms (${dialogsList.size} items)")
|
||||
}
|
||||
}
|
||||
}
|
||||
.distinctUntilChanged() // 🔥 ИСПРАВЛЕНИЕ: Игнорируем дублирующиеся списки
|
||||
.collect { decryptedDialogs ->
|
||||
android.util.Log.d(TAG, "✅ Dialogs collected: ${decryptedDialogs.size} items")
|
||||
_dialogs.value = decryptedDialogs
|
||||
|
||||
// 🟢 Подписываемся на онлайн-статусы всех собеседников
|
||||
|
||||
@@ -66,6 +66,37 @@ fun ForwardChatPickerBottomSheet(
|
||||
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
|
||||
}
|
||||
|
||||
// 🎨 Плавное затемнение статус бара когда bottom sheet открыт
|
||||
DisposableEffect(Unit) {
|
||||
if (!view.isInEditMode) {
|
||||
val window = (view.context as? android.app.Activity)?.window
|
||||
val originalStatusBarColor = window?.statusBarColor ?: 0
|
||||
val scrimColor = android.graphics.Color.argb(153, 0, 0, 0) // 60% черный
|
||||
|
||||
// Плавное затемнение
|
||||
val fadeInAnimator = android.animation.ValueAnimator.ofArgb(originalStatusBarColor, scrimColor).apply {
|
||||
duration = 200
|
||||
addUpdateListener { animator ->
|
||||
window?.statusBarColor = animator.animatedValue as Int
|
||||
}
|
||||
}
|
||||
fadeInAnimator.start()
|
||||
|
||||
onDispose {
|
||||
// Плавное восстановление
|
||||
val fadeOutAnimator = android.animation.ValueAnimator.ofArgb(scrimColor, originalStatusBarColor).apply {
|
||||
duration = 150
|
||||
addUpdateListener { animator ->
|
||||
window?.statusBarColor = animator.animatedValue as Int
|
||||
}
|
||||
}
|
||||
fadeOutAnimator.start()
|
||||
}
|
||||
} else {
|
||||
onDispose { }
|
||||
}
|
||||
}
|
||||
|
||||
// 🔥 Функция для красивого закрытия с анимацией
|
||||
fun dismissWithAnimation() {
|
||||
scope.launch {
|
||||
|
||||
@@ -183,7 +183,6 @@ fun InAppCameraScreen(
|
||||
}
|
||||
|
||||
override fun onError(exc: ImageCaptureException) {
|
||||
Log.e("InAppCamera", "Photo capture failed: ${exc.message}", exc)
|
||||
isCapturing = false
|
||||
}
|
||||
}
|
||||
@@ -227,7 +226,6 @@ fun InAppCameraScreen(
|
||||
capture
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
Log.e("InAppCamera", "Use case binding failed", e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user