mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-22 21:58:53 +01:00
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:
@@ -48,4 +48,5 @@ data class ComposeState(
|
|||||||
val canSend: Boolean = false,
|
val canSend: Boolean = false,
|
||||||
val validRecipientNumbers: Int = 1,
|
val validRecipientNumbers: Int = 1,
|
||||||
val audioMsgRecording: Boolean = false,
|
val audioMsgRecording: Boolean = false,
|
||||||
|
val saveDraft: Boolean = true,
|
||||||
)
|
)
|
||||||
@@ -328,6 +328,7 @@ class ComposeViewModel @Inject constructor(
|
|||||||
view.optionsItemIntent
|
view.optionsItemIntent
|
||||||
.filter { it == R.id.add }
|
.filter { it == R.id.add }
|
||||||
.withLatestFrom(selectedChips) { _, chips ->
|
.withLatestFrom(selectedChips) { _, chips ->
|
||||||
|
newState { copy(saveDraft = false) } // do not save draft on next activity invisibility
|
||||||
view.showContacts(sharing, chips)
|
view.showContacts(sharing, chips)
|
||||||
}
|
}
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
@@ -643,8 +644,10 @@ class ComposeViewModel @Inject constructor(
|
|||||||
.withLatestFrom(conversation) { _, conversation -> conversation }
|
.withLatestFrom(conversation) { _, conversation -> conversation }
|
||||||
.mapNotNull { conversation -> conversation.takeIf { it.isValid }?.id }
|
.mapNotNull { conversation -> conversation.takeIf { it.isValid }?.id }
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.withLatestFrom(view.textChangedIntent) { threadId, draft ->
|
.withLatestFrom(view.textChangedIntent, state) { threadId, draftText, state ->
|
||||||
conversationRepo.saveDraft(threadId, draft.toString())
|
if (state.saveDraft)
|
||||||
|
conversationRepo.saveDraft(threadId, draftText.toString())
|
||||||
|
newState { copy(saveDraft = true) }
|
||||||
}
|
}
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe()
|
.subscribe()
|
||||||
|
|||||||
Reference in New Issue
Block a user