Skip to content

Commit 7b8bd14

Browse files
nbradburyclaude
andcommitted
RS Post Settings: Use site null check instead of apiClient
Check `site == null` instead of `apiClient == null` to avoid triggering unnecessary lazy evaluation and to match the original guard pattern the code previously used. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 22cf260 commit 7b8bd14

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

WordPress/src/main/java/org/wordpress/android/ui/postsrs/PostRsSettingsViewModel.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import org.wordpress.android.ui.postsrs.data.PostRsRestClient
2222
import org.wordpress.android.util.AppLog
2323
import org.wordpress.android.util.NetworkUtilsWrapper
2424
import org.wordpress.android.viewmodel.ResourceProvider
25-
import rs.wordpress.api.kotlin.WpApiClient
2625
import rs.wordpress.api.kotlin.WpRequestResult
2726
import uniffi.wp_api.AnyPostWithEditContext
2827
import uniffi.wp_api.PostEndpointType
@@ -53,7 +52,7 @@ class PostRsSettingsViewModel @Inject constructor(
5352

5453
private val site = selectedSiteRepository.getSelectedSite()
5554

56-
private val apiClient: WpApiClient? by lazy {
55+
private val apiClient by lazy {
5756
site?.let { wpApiClientProvider.getWpApiClient(it) }
5857
}
5958

@@ -89,7 +88,7 @@ class PostRsSettingsViewModel @Inject constructor(
8988

9089
@Suppress("TooGenericExceptionCaught")
9190
fun refreshPost() {
92-
if (apiClient == null) return
91+
if (site == null) return
9392
if (!networkUtilsWrapper.isNetworkAvailable()) {
9493
_snackbarMessages.trySend(
9594
SnackbarMessage(
@@ -673,7 +672,7 @@ class PostRsSettingsViewModel @Inject constructor(
673672
}
674673

675674
private fun loadPost() {
676-
if (apiClient == null) return
675+
if (site == null) return
677676
if (!networkUtilsWrapper.isNetworkAvailable()) {
678677
_uiState.value = PostRsSettingsUiState(
679678
isLoading = false,

0 commit comments

Comments
 (0)