Add draft support for qkreply

This commit is contained in:
Moez Bhatti
2018-03-28 20:24:33 -04:00
parent c617377ca4
commit d26adad7bf
@@ -61,7 +61,7 @@ class QkReplyViewModel(intent: Intent) : QkViewModel<QkReplyView, QkReplyState>(
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<QkReplyView, QkReplyState>(
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 }