Skip to content

Commit b46cbdc

Browse files
committed
fix: deprecated ListItemColor.copy()
* play around with explicit backing fields, which need extra options in Android Studio * remove deprecated login page
1 parent 7783a3f commit b46cbdc

File tree

5 files changed

+16
-436
lines changed

5 files changed

+16
-436
lines changed

app/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ plugins {
1515
alias(libs.plugins.aboutlibraries.android)
1616
}
1717

18+
private val isInIdeaSync
19+
get() = System.getProperty("idea.sync.active").toBoolean()
20+
1821
kotlin {
1922
compilerOptions {
2023
jvmToolchain(21)
@@ -24,6 +27,10 @@ kotlin {
2427
jvmTarget = JvmTarget.JVM_21
2528
freeCompilerArgs.add("-Xannotation-default-target=param-property")
2629
freeCompilerArgs.add("-Xexplicit-backing-fields")
30+
// WORKAROUND: https://youtrack.jetbrains.com/issue/KT-83265/How-to-disable-Explicit-Backing-Fields-compiler-warning
31+
if (isInIdeaSync) {
32+
freeCompilerArgs.add("-XXLanguage:+ExplicitBackingFields")
33+
}
2734
}
2835
}
2936

app/src/main/kotlin/day/vitayuzu/neodb/ui/page/home/HomeViewModel.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import kotlinx.coroutines.async
1313
import kotlinx.coroutines.awaitAll
1414
import kotlinx.coroutines.cancelAndJoin
1515
import kotlinx.coroutines.flow.MutableStateFlow
16-
import kotlinx.coroutines.flow.asStateFlow
16+
import kotlinx.coroutines.flow.StateFlow
1717
import kotlinx.coroutines.flow.distinctUntilChanged
1818
import kotlinx.coroutines.flow.distinctUntilChangedBy
1919
import kotlinx.coroutines.flow.filter
@@ -32,8 +32,8 @@ class HomeViewModel @Inject constructor(
3232
authRepository: AuthRepository,
3333
) : ViewModel() {
3434

35-
private val _uiState = MutableStateFlow(HomeUiState())
36-
val uiState = _uiState.asStateFlow()
35+
val uiState: StateFlow<HomeUiState>
36+
field = MutableStateFlow(HomeUiState())
3737

3838
private var refreshJob: Job? = null
3939

@@ -59,7 +59,7 @@ class HomeViewModel @Inject constructor(
5959
viewModelScope.launch {
6060
refreshJob?.cancelAndJoin()
6161
// Should after job cancellation since it will toggle it to false
62-
_uiState.update { it.copy(isLoading = true) }
62+
uiState.update { it.copy(isLoading = true) }
6363
refreshJob = viewModelScope
6464
.launch {
6565
val jobs = enabledTrendingTypes.map {
@@ -70,13 +70,13 @@ class HomeViewModel @Inject constructor(
7070
.map { Entry(it) }
7171
}
7272
}
73-
_uiState.update {
73+
uiState.update {
7474
it.copy(
7575
data = enabledTrendingTypes.zip(jobs.awaitAll()).toMap(),
7676
)
7777
}
7878
}.apply {
79-
invokeOnCompletion { _uiState.update { it.copy(isLoading = false) } }
79+
invokeOnCompletion { uiState.update { it.copy(isLoading = false) } }
8080
}
8181
}
8282
}

0 commit comments

Comments
 (0)