Remove unnecessary logging statements across various components to clean up code and improve readability. This includes removing debug, error, and warning logs from attachment handling, image processing, media loading, and profile management functionalities. Additionally, a script has been added to automate the removal of log statements from Kotlin files.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package com.rosetta.messenger.repository
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.rosetta.messenger.database.AvatarCacheEntity
|
||||
import com.rosetta.messenger.database.AvatarDao
|
||||
import com.rosetta.messenger.utils.AvatarFileManager
|
||||
@@ -57,7 +56,6 @@ class AvatarRepository(
|
||||
// Подписываемся на изменения в БД с использованием repository scope
|
||||
avatarDao.getAvatars(publicKey)
|
||||
.onEach { entities ->
|
||||
Log.d(TAG, "📥 DB update for $publicKey: ${entities.size} entities")
|
||||
val avatars = if (allDecode) {
|
||||
// Загружаем всю историю
|
||||
entities.mapNotNull { entity ->
|
||||
@@ -70,7 +68,6 @@ class AvatarRepository(
|
||||
}?.let { listOf(it) } ?: emptyList()
|
||||
}
|
||||
flow.value = avatars
|
||||
Log.d(TAG, "✅ Flow updated for $publicKey: ${avatars.size} avatars")
|
||||
}
|
||||
.launchIn(repositoryScope)
|
||||
|
||||
@@ -97,7 +94,6 @@ class AvatarRepository(
|
||||
try {
|
||||
// Сохраняем файл
|
||||
val filePath = AvatarFileManager.saveAvatar(context, base64Image, fromPublicKey)
|
||||
Log.d(TAG, "💾 Avatar file saved for $fromPublicKey: $filePath")
|
||||
|
||||
// Сохраняем в БД
|
||||
val entity = AvatarCacheEntity(
|
||||
@@ -106,7 +102,6 @@ class AvatarRepository(
|
||||
timestamp = System.currentTimeMillis()
|
||||
)
|
||||
avatarDao.insertAvatar(entity)
|
||||
Log.d(TAG, "💾 Avatar entity inserted to DB for $fromPublicKey")
|
||||
|
||||
// Очищаем старые аватары (оставляем только последние N)
|
||||
avatarDao.deleteOldAvatars(fromPublicKey, MAX_AVATAR_HISTORY)
|
||||
@@ -117,15 +112,11 @@ class AvatarRepository(
|
||||
val avatarInfo = loadAndDecryptAvatar(entity)
|
||||
if (avatarInfo != null) {
|
||||
cachedFlow.value = listOf(avatarInfo)
|
||||
Log.d(TAG, "✅ Memory cache updated for $fromPublicKey")
|
||||
}
|
||||
} else {
|
||||
Log.d(TAG, "ℹ️ No memory cache for $fromPublicKey, will be loaded on next getAvatars()")
|
||||
}
|
||||
|
||||
Log.d(TAG, "✅ Saved avatar for $fromPublicKey")
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "❌ Failed to save avatar for $fromPublicKey", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,13 +130,9 @@ class AvatarRepository(
|
||||
suspend fun changeMyAvatar(base64Image: String) {
|
||||
withContext(Dispatchers.IO) {
|
||||
try {
|
||||
Log.d(TAG, "🔄 changeMyAvatar called")
|
||||
Log.d(TAG, "👤 Current public key: ${currentPublicKey.take(16)}...")
|
||||
Log.d(TAG, "📊 Base64 image length: ${base64Image.length} chars")
|
||||
|
||||
// Сохраняем файл
|
||||
val filePath = AvatarFileManager.saveAvatar(context, base64Image, currentPublicKey)
|
||||
Log.d(TAG, "✅ Avatar file saved: $filePath")
|
||||
|
||||
// Сохраняем в БД
|
||||
val entity = AvatarCacheEntity(
|
||||
@@ -154,14 +141,11 @@ class AvatarRepository(
|
||||
timestamp = System.currentTimeMillis()
|
||||
)
|
||||
avatarDao.insertAvatar(entity)
|
||||
Log.d(TAG, "✅ Avatar inserted to DB")
|
||||
|
||||
// Очищаем старые аватары
|
||||
avatarDao.deleteOldAvatars(currentPublicKey, MAX_AVATAR_HISTORY)
|
||||
|
||||
Log.d(TAG, "🎉 Avatar changed successfully!")
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "❌ Failed to change avatar: ${e.message}", e)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
@@ -173,8 +157,6 @@ class AvatarRepository(
|
||||
suspend fun deleteMyAvatar() {
|
||||
withContext(Dispatchers.IO) {
|
||||
try {
|
||||
Log.d(TAG, "🗑️ deleteMyAvatar called")
|
||||
Log.d(TAG, "👤 Current public key: ${currentPublicKey.take(16)}...")
|
||||
|
||||
// Получаем все аватары пользователя
|
||||
val avatars = avatarDao.getAvatarsByPublicKey(currentPublicKey)
|
||||
@@ -183,22 +165,17 @@ class AvatarRepository(
|
||||
for (avatar in avatars) {
|
||||
try {
|
||||
AvatarFileManager.deleteAvatar(context, avatar.avatar)
|
||||
Log.d(TAG, "✅ Deleted avatar file: ${avatar.avatar}")
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "⚠️ Failed to delete avatar file: ${avatar.avatar}", e)
|
||||
}
|
||||
}
|
||||
|
||||
// Удаляем из БД
|
||||
avatarDao.deleteAllAvatars(currentPublicKey)
|
||||
Log.d(TAG, "✅ Avatars deleted from DB")
|
||||
|
||||
// Очищаем memory cache
|
||||
memoryCache.remove(currentPublicKey)
|
||||
|
||||
Log.d(TAG, "🎉 Avatar deleted successfully!")
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "❌ Failed to delete avatar: ${e.message}", e)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
@@ -217,11 +194,9 @@ class AvatarRepository(
|
||||
timestamp = entity.timestamp
|
||||
)
|
||||
} else {
|
||||
Log.w(TAG, "Failed to read avatar file: ${entity.avatar}")
|
||||
null
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Failed to load avatar", e)
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user