feat: implement delivery status updates and enhance file size limit for uploads

This commit is contained in:
k1ngsterr1
2026-02-06 03:17:22 +05:00
parent 0bd8cb39ab
commit dcc719ec56
7 changed files with 115 additions and 23 deletions

View File

@@ -74,7 +74,21 @@ class MessageRepository private constructor(private val context: Context) {
onBufferOverflow = kotlinx.coroutines.channels.BufferOverflow.DROP_OLDEST
)
val newMessageEvents: SharedFlow<String> = _newMessageEvents.asSharedFlow()
// 🔔 События обновления статуса доставки для UI
data class DeliveryStatusUpdate(
val dialogKey: String,
val messageId: String,
val status: DeliveryStatus
)
private val _deliveryStatusEvents = MutableSharedFlow<DeliveryStatusUpdate>(
replay = 0,
extraBufferCapacity = 64,
onBufferOverflow = kotlinx.coroutines.channels.BufferOverflow.DROP_OLDEST
)
val deliveryStatusEvents: SharedFlow<DeliveryStatusUpdate> = _deliveryStatusEvents.asSharedFlow()
// 🔥 Tracking для уже запрошенных user info - предотвращает бесконечные запросы
private val requestedUserInfoKeys = mutableSetOf<String>()
@@ -511,11 +525,16 @@ class MessageRepository private constructor(private val context: Context) {
// Обновляем кэш
val dialogKey = getDialogKey(packet.toPublicKey)
updateMessageStatus(dialogKey, packet.messageId, DeliveryStatus.DELIVERED)
// 🔔 Уведомляем UI о смене статуса доставки
_deliveryStatusEvents.tryEmit(
DeliveryStatusUpdate(dialogKey, packet.messageId, DeliveryStatus.DELIVERED)
)
// 🔥 КРИТИЧНО: Обновляем диалог чтобы lastMessageDelivered обновился
dialogDao.updateDialogFromMessages(account, packet.toPublicKey)
}
/**
* Обработка прочтения
* В Desktop PacketRead сообщает что собеседник прочитал наши сообщения
@@ -544,7 +563,12 @@ class MessageRepository private constructor(private val context: Context) {
else msg
}
}
// 🔔 Уведомляем UI о прочтении (пустой messageId = все исходящие сообщения)
_deliveryStatusEvents.tryEmit(
DeliveryStatusUpdate(dialogKey, "", DeliveryStatus.READ)
)
// 📝 LOG: Статус прочтения
MessageLogger.logReadStatus(
fromPublicKey = packet.fromPublicKey,