From e032d38d56fe7618f49bced6cdbcc02673ffa6e1 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Mon, 31 May 2021 15:16:07 +0200 Subject: [PATCH] fix LiveData nullability issues (#2181) --- .../components/announcements/AnnouncementsViewModel.kt | 2 +- .../components/conversation/ConversationsRepository.kt | 2 +- .../tusky/components/report/ReportViewModel.kt | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementsViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementsViewModel.kt index 3a09b5b03..2b4d61a40 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementsViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementsViewModel.kt @@ -67,7 +67,7 @@ class AnnouncementsViewModel @Inject constructor( appDatabase.instanceDao().insertOrReplace(it) } .subscribe({ - emojisMutable.postValue(it.emojiList) + emojisMutable.postValue(it.emojiList.orEmpty()) }, { Log.w(TAG, "Failed to get custom emojis.", it) }) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsRepository.kt b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsRepository.kt index d4c8c72ed..e3703cbfe 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsRepository.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsRepository.kt @@ -71,7 +71,7 @@ class ConversationsRepository @Inject constructor(val mastodonApi: MastodonApi, // we are using a mutable live data to trigger refresh requests which eventually calls // refresh method and gets a new live data. Each refresh request by the user becomes a newly // dispatched data in refreshTrigger - val refreshTrigger = MutableLiveData() + val refreshTrigger = MutableLiveData() val refreshState = Transformations.switchMap(refreshTrigger) { refresh(accountId, true) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/report/ReportViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/report/ReportViewModel.kt index f2a97be56..e5691473d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/report/ReportViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/report/ReportViewModel.kt @@ -37,8 +37,8 @@ class ReportViewModel @Inject constructor( private val eventHub: EventHub, private val statusesRepository: StatusesRepository) : RxAwareViewModel() { - private val navigationMutable = MutableLiveData() - val navigation: LiveData = navigationMutable + private val navigationMutable = MutableLiveData() + val navigation: LiveData = navigationMutable private val muteStateMutable = MutableLiveData>() val muteState: LiveData> = muteStateMutable @@ -49,8 +49,8 @@ class ReportViewModel @Inject constructor( private val reportingStateMutable = MutableLiveData>() var reportingState: LiveData> = reportingStateMutable - private val checkUrlMutable = MutableLiveData() - val checkUrl: LiveData = checkUrlMutable + private val checkUrlMutable = MutableLiveData() + val checkUrl: LiveData = checkUrlMutable private val repoResult = MutableLiveData>() val statuses: LiveData> = Transformations.switchMap(repoResult) { it.pagedList }