From d26adad7bf4051dce8d7fb184dd4712ab85e2ba1 Mon Sep 17 00:00:00 2001 From: Moez Bhatti Date: Wed, 28 Mar 2018 20:24:33 -0400 Subject: [PATCH] Add draft support for qkreply --- .../src/main/java/feature/qkreply/QkReplyViewModel.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 }