Доработки звонков и чатов: typing, UI и стабильность

This commit is contained in:
2026-04-04 15:17:47 +05:00
parent a9be1282c6
commit 6886a6cef1
17 changed files with 764 additions and 162 deletions

View File

@@ -46,19 +46,24 @@ object DraftManager {
fun saveDraft(opponentKey: String, text: String) {
if (currentAccount.isEmpty()) return
val trimmed = text.trim()
val currentDrafts = _drafts.value.toMutableMap()
val hasContent = text.any { !it.isWhitespace() }
val existing = _drafts.value[opponentKey]
if (trimmed.isEmpty()) {
if (!hasContent) {
if (existing == null) return
val currentDrafts = _drafts.value.toMutableMap()
// Удаляем черновик если текст пустой
currentDrafts.remove(opponentKey)
prefs?.edit()?.remove(prefKey(opponentKey))?.apply()
_drafts.value = currentDrafts
} else {
currentDrafts[opponentKey] = trimmed
prefs?.edit()?.putString(prefKey(opponentKey), trimmed)?.apply()
// Ничего не делаем, если текст не изменился — это частый путь при больших вставках.
if (existing == text) return
val currentDrafts = _drafts.value.toMutableMap()
currentDrafts[opponentKey] = text
prefs?.edit()?.putString(prefKey(opponentKey), text)?.apply()
_drafts.value = currentDrafts
}
_drafts.value = currentDrafts
}
/** Получить черновик для диалога */