Don't trampoline in setOnlyPage.

fork-5.53.8
Alex Hart 2022-02-11 11:09:13 -04:00 zatwierdzone przez GitHub
rodzic b56207d977
commit 90e6dd3d7d
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 9 dodań i 2 usunięć

Wyświetl plik

@ -1,7 +1,9 @@
package org.thoughtcrime.securesms.keyboard
import androidx.annotation.MainThread
import androidx.lifecycle.LiveData
import androidx.lifecycle.ViewModel
import org.signal.core.util.ThreadUtil
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.stickers.StickerSearchRepository
@ -35,14 +37,19 @@ class KeyboardPagerViewModel : ViewModel() {
fun page(): LiveData<KeyboardPage> = page
fun pages(): LiveData<Set<KeyboardPage>> = pages
@MainThread
fun setOnlyPage(page: KeyboardPage) {
pages.postValue(setOf(page))
pages.value = setOf(page)
switchToPage(page)
}
fun switchToPage(page: KeyboardPage) {
if (this.pages.value.contains(page) && this.page.value != page) {
this.page.postValue(page)
if (ThreadUtil.isMainThread()) {
this.page.value = page
} else {
this.page.postValue(page)
}
}
}
}