Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -151,8 +151,10 @@ class MessageRepository private constructor(private val context: Context) {
|
||||
attachments: List<MessageAttachment> = emptyList(),
|
||||
replyToMessageId: String? = null
|
||||
): Message {
|
||||
android.util.Log.d("MessageRepo", "📤 sendMessage START: to=${toPublicKey.take(16)}...")
|
||||
val account = currentAccount ?: throw IllegalStateException("Not initialized")
|
||||
val privateKey = currentPrivateKey ?: throw IllegalStateException("Not initialized")
|
||||
android.util.Log.d("MessageRepo", "📤 sendMessage: account=${account.take(16)}...")
|
||||
|
||||
val messageId = UUID.randomUUID().toString().replace("-", "").take(32)
|
||||
val timestamp = System.currentTimeMillis()
|
||||
@@ -217,7 +219,8 @@ class MessageRepository private constructor(private val context: Context) {
|
||||
updateDialog(toPublicKey, text.trim(), timestamp)
|
||||
|
||||
// 🔥 Отмечаем что я отправлял сообщения в этот диалог (перемещает из requests в chats)
|
||||
dialogDao.markIHaveSent(account, toPublicKey)
|
||||
val updatedRows = dialogDao.markIHaveSent(account, toPublicKey)
|
||||
android.util.Log.d("MessageRepo", "📤 MARKED i_have_sent=1 for opponent=${toPublicKey.take(16)}..., updatedRows=$updatedRows")
|
||||
|
||||
// Отправляем пакет
|
||||
val packet = PacketMessage().apply {
|
||||
@@ -536,10 +539,15 @@ class MessageRepository private constructor(private val context: Context) {
|
||||
suspend fun updateDialogUserInfo(publicKey: String, title: String, username: String, verified: Int) {
|
||||
val account = currentAccount ?: return
|
||||
|
||||
android.util.Log.d("MessageRepo", "📋 updateDialogUserInfo: publicKey=${publicKey.take(16)}..., title=$title, username=$username")
|
||||
|
||||
// Проверяем существует ли диалог с этим пользователем
|
||||
val existing = dialogDao.getDialog(account, publicKey)
|
||||
if (existing != null) {
|
||||
android.util.Log.d("MessageRepo", "📋 Updating existing dialog info for ${publicKey.take(16)}...")
|
||||
dialogDao.updateOpponentInfo(account, publicKey, title, username, verified)
|
||||
} else {
|
||||
android.util.Log.d("MessageRepo", "📋 Dialog not found for ${publicKey.take(16)}..., skipping")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user