diff --git a/presentation/src/main/java/feature/qkreply/QkReplyViewModel.kt b/presentation/src/main/java/feature/qkreply/QkReplyViewModel.kt index c2b85ca8..99c0be5f 100644 --- a/presentation/src/main/java/feature/qkreply/QkReplyViewModel.kt +++ b/presentation/src/main/java/feature/qkreply/QkReplyViewModel.kt @@ -61,7 +61,7 @@ class QkReplyViewModel(intent: Intent) : QkViewModel( disposables += conversation .doOnNext { conversation -> newState { it.copy(title = conversation.getTitle()) } } - .take(1) // We only need to set the messages once + .distinctUntilChanged { conversation -> conversation.id } // We only need to set the messages once .map { conversation -> Pair(conversation, messageRepo.getUnreadMessages(conversation.id)) } .subscribe { data -> newState { it.copy(data = data) } } } @@ -69,6 +69,12 @@ class QkReplyViewModel(intent: Intent) : QkViewModel( override fun bindView(view: QkReplyView) { super.bindView(view) + conversation + .map { conversation -> conversation.draft } + .distinctUntilChanged() + .autoDisposable(view.scope()) + .subscribe { draft -> view.setDraft(draft) } + // Mark read view.menuItemIntent .filter { id -> id == R.id.read }