Доработки звонков и чатов: typing, UI и стабильность
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
/** Получить черновик для диалога */
|
||||
|
||||
Reference in New Issue
Block a user