forked from upstream-mirrors/quik
If viewing notification prefs for particular conversation, set title to conversation name
This commit is contained in:
@@ -49,7 +49,7 @@ class GalleryViewModel(intent: Intent) : QkViewModel<GalleryView, GalleryState>(
|
|||||||
disposables += partIdFlowable
|
disposables += partIdFlowable
|
||||||
.mapNotNull { partId -> messageRepo.getMessageForPart(partId) }
|
.mapNotNull { partId -> messageRepo.getMessageForPart(partId) }
|
||||||
.mapNotNull { message -> messageRepo.getConversation(message.threadId) }
|
.mapNotNull { message -> messageRepo.getConversation(message.threadId) }
|
||||||
.subscribe { conversation -> newState { it.copy(title = conversation.getTitle()) } }
|
.subscribe { conversation -> newState { it.copy(title = conversation.getTitle()) } }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun bindView(view: GalleryView) {
|
override fun bindView(view: GalleryView) {
|
||||||
|
|||||||
+4
@@ -73,6 +73,10 @@ class NotificationPrefsActivity : QkThemedActivity<NotificationPrefsViewModel>()
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun render(state: NotificationPrefsState) {
|
override fun render(state: NotificationPrefsState) {
|
||||||
|
if (state.conversationTitle.isNotEmpty()) {
|
||||||
|
title = state.conversationTitle
|
||||||
|
}
|
||||||
|
|
||||||
notifications.checkbox.isChecked = state.notificationsEnabled
|
notifications.checkbox.isChecked = state.notificationsEnabled
|
||||||
vibration.checkbox.isChecked = state.vibrationEnabled
|
vibration.checkbox.isChecked = state.vibrationEnabled
|
||||||
ringtone.summary = state.ringtoneName
|
ringtone.summary = state.ringtoneName
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
package presentation.feature.notificationprefs
|
package presentation.feature.notificationprefs
|
||||||
|
|
||||||
data class NotificationPrefsState(
|
data class NotificationPrefsState(
|
||||||
|
val conversationTitle: String = "",
|
||||||
val notificationsEnabled: Boolean = true,
|
val notificationsEnabled: Boolean = true,
|
||||||
val vibrationEnabled: Boolean = true,
|
val vibrationEnabled: Boolean = true,
|
||||||
val ringtoneName: String = ""
|
val ringtoneName: String = ""
|
||||||
|
|||||||
+11
@@ -29,7 +29,11 @@ import com.uber.autodispose.android.lifecycle.scope
|
|||||||
import com.uber.autodispose.kotlin.autoDisposable
|
import com.uber.autodispose.kotlin.autoDisposable
|
||||||
import common.di.appComponent
|
import common.di.appComponent
|
||||||
import common.util.Preferences
|
import common.util.Preferences
|
||||||
|
import common.util.extensions.mapNotNull
|
||||||
|
import data.repository.MessageRepository
|
||||||
|
import io.reactivex.Flowable
|
||||||
import io.reactivex.rxkotlin.plusAssign
|
import io.reactivex.rxkotlin.plusAssign
|
||||||
|
import io.reactivex.schedulers.Schedulers
|
||||||
import presentation.common.Navigator
|
import presentation.common.Navigator
|
||||||
import presentation.common.base.QkViewModel
|
import presentation.common.base.QkViewModel
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
@@ -38,6 +42,7 @@ import javax.inject.Inject
|
|||||||
class NotificationPrefsViewModel(intent: Intent) : QkViewModel<NotificationPrefsView, NotificationPrefsState>(NotificationPrefsState()) {
|
class NotificationPrefsViewModel(intent: Intent) : QkViewModel<NotificationPrefsView, NotificationPrefsState>(NotificationPrefsState()) {
|
||||||
|
|
||||||
@Inject lateinit var context: Context
|
@Inject lateinit var context: Context
|
||||||
|
@Inject lateinit var messageRepo: MessageRepository
|
||||||
@Inject lateinit var navigator: Navigator
|
@Inject lateinit var navigator: Navigator
|
||||||
@Inject lateinit var prefs: Preferences
|
@Inject lateinit var prefs: Preferences
|
||||||
|
|
||||||
@@ -54,6 +59,12 @@ class NotificationPrefsViewModel(intent: Intent) : QkViewModel<NotificationPrefs
|
|||||||
vibration = prefs.vibration(threadId)
|
vibration = prefs.vibration(threadId)
|
||||||
ringtone = prefs.ringtone(threadId)
|
ringtone = prefs.ringtone(threadId)
|
||||||
|
|
||||||
|
disposables += Flowable.just(threadId)
|
||||||
|
.mapNotNull { threadId -> messageRepo.getConversation(threadId) }
|
||||||
|
.map { conversation -> conversation.getTitle() }
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.subscribe { title -> newState { it.copy(conversationTitle = title) } }
|
||||||
|
|
||||||
disposables += notifications.asObservable()
|
disposables += notifications.asObservable()
|
||||||
.subscribe { enabled -> newState { it.copy(notificationsEnabled = enabled) } }
|
.subscribe { enabled -> newState { it.copy(notificationsEnabled = enabled) } }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user