mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-09 19:52:44 +02:00
Removing unecessary livedata objects for translation services
This commit is contained in:
@@ -219,7 +219,6 @@ class Account(
|
|||||||
|
|
||||||
// Observers line up here.
|
// Observers line up here.
|
||||||
val live: AccountLiveData = AccountLiveData(this)
|
val live: AccountLiveData = AccountLiveData(this)
|
||||||
val liveLanguages: AccountLiveData = AccountLiveData(this)
|
|
||||||
val saveable: AccountLiveData = AccountLiveData(this)
|
val saveable: AccountLiveData = AccountLiveData(this)
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@@ -2831,21 +2830,16 @@ class Account(
|
|||||||
|
|
||||||
fun updateLocalRelayServers(servers: Set<String>) {
|
fun updateLocalRelayServers(servers: Set<String>) {
|
||||||
localRelayServers = servers
|
localRelayServers = servers
|
||||||
liveLanguages.invalidateData()
|
|
||||||
saveable.invalidateData()
|
saveable.invalidateData()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addDontTranslateFrom(languageCode: String) {
|
fun addDontTranslateFrom(languageCode: String) {
|
||||||
dontTranslateFrom = dontTranslateFrom.plus(languageCode)
|
dontTranslateFrom = dontTranslateFrom.plus(languageCode)
|
||||||
liveLanguages.invalidateData()
|
|
||||||
|
|
||||||
saveable.invalidateData()
|
saveable.invalidateData()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateTranslateTo(languageCode: String) {
|
fun updateTranslateTo(languageCode: String) {
|
||||||
translateTo = languageCode
|
translateTo = languageCode
|
||||||
liveLanguages.invalidateData()
|
|
||||||
|
|
||||||
saveable.invalidateData()
|
saveable.invalidateData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -148,7 +148,6 @@ class AccountViewModel(
|
|||||||
) : ViewModel(),
|
) : ViewModel(),
|
||||||
Dao {
|
Dao {
|
||||||
val accountLiveData: LiveData<AccountState> = account.live.map { it }
|
val accountLiveData: LiveData<AccountState> = account.live.map { it }
|
||||||
val accountLanguagesLiveData: LiveData<AccountState> = account.liveLanguages.map { it }
|
|
||||||
|
|
||||||
// TODO: contact lists are not notes yet
|
// TODO: contact lists are not notes yet
|
||||||
// val kind3Relays: StateFlow<ContactListEvent?> = observeByAuthor(ContactListEvent.KIND, account.signer.pubKey)
|
// val kind3Relays: StateFlow<ContactListEvent?> = observeByAuthor(ContactListEvent.KIND, account.signer.pubKey)
|
||||||
|
@@ -42,7 +42,6 @@ import androidx.compose.runtime.LaunchedEffect
|
|||||||
import androidx.compose.runtime.MutableState
|
import androidx.compose.runtime.MutableState
|
||||||
import androidx.compose.runtime.derivedStateOf
|
import androidx.compose.runtime.derivedStateOf
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.livedata.observeAsState
|
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
@@ -366,9 +365,10 @@ fun TranslateAndWatchLanguageChanges(
|
|||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
onTranslated: (TranslationConfig) -> Unit,
|
onTranslated: (TranslationConfig) -> Unit,
|
||||||
) {
|
) {
|
||||||
val accountState by accountViewModel.accountLanguagesLiveData.observeAsState()
|
// Don't automatically update translations.
|
||||||
|
// val accountState by accountViewModel.accountLanguagesLiveData.observeAsState()
|
||||||
|
|
||||||
LaunchedEffect(accountState) {
|
LaunchedEffect(Unit) {
|
||||||
// This takes some time. Launches as a Composition scope to make sure this gets cancel if this
|
// This takes some time. Launches as a Composition scope to make sure this gets cancel if this
|
||||||
// item gets out of view.
|
// item gets out of view.
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
|
Reference in New Issue
Block a user