Merge pull request #356 from gavine99/duplicate-drafts-for-first-member-of-group-messages-187

do not save draft text when adding new recipients to group convo
This commit is contained in:
octoshrimpy
2025-03-15 17:39:38 -04:00
committed by GitHub
2 changed files with 6 additions and 2 deletions
@@ -48,4 +48,5 @@ data class ComposeState(
val canSend: Boolean = false,
val validRecipientNumbers: Int = 1,
val audioMsgRecording: Boolean = false,
val saveDraft: Boolean = true,
)
@@ -328,6 +328,7 @@ class ComposeViewModel @Inject constructor(
view.optionsItemIntent
.filter { it == R.id.add }
.withLatestFrom(selectedChips) { _, chips ->
newState { copy(saveDraft = false) } // do not save draft on next activity invisibility
view.showContacts(sharing, chips)
}
.autoDisposable(view.scope())
@@ -643,8 +644,10 @@ class ComposeViewModel @Inject constructor(
.withLatestFrom(conversation) { _, conversation -> conversation }
.mapNotNull { conversation -> conversation.takeIf { it.isValid }?.id }
.observeOn(Schedulers.io())
.withLatestFrom(view.textChangedIntent) { threadId, draft ->
conversationRepo.saveDraft(threadId, draft.toString())
.withLatestFrom(view.textChangedIntent, state) { threadId, draftText, state ->
if (state.saveDraft)
conversationRepo.saveDraft(threadId, draftText.toString())
newState { copy(saveDraft = true) }
}
.autoDisposable(view.scope())
.subscribe()