Просмотр исходного кода

fix: restore verification after source screen updates

HapeLee 3 месяцев назад
Родитель
Сommit
f265160af5

+ 2 - 1
app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceScreen.kt

@@ -159,6 +159,7 @@ fun BookSourceScreen(
     }
     val snackbarHostState = remember { SnackbarHostState() }
     val clipboardManager = LocalClipboard.current
+    val cancelLabel = stringResource(R.string.cancel)
     LaunchedEffect(Unit) {
         effects.collectLatest { effect ->
             when (effect) {
@@ -181,7 +182,7 @@ fun BookSourceScreen(
         val progress = state.checkProgress ?: return@LaunchedEffect
         val result = snackbarHostState.showSnackbar(
             message = progress,
-            actionLabel = context.getString(R.string.cancel),
+            actionLabel = cancelLabel,
             withDismissAction = false,
             duration = androidx.compose.material3.SnackbarDuration.Indefinite,
         )

+ 0 - 32
app/src/test/java/io/legado/app/ui/config/otherConfig/OtherConfigViewModelTest.kt

@@ -4,8 +4,6 @@ import android.app.Application
 import android.os.Looper
 import io.legado.app.R
 import io.legado.app.domain.gateway.AppLocaleGateway
-import io.legado.app.domain.gateway.CheckSourceSettings
-import io.legado.app.domain.gateway.CheckSourceSettingsGateway
 import io.legado.app.domain.gateway.DirectLinkRule
 import io.legado.app.domain.gateway.DirectLinkSettingsGateway
 import io.legado.app.domain.gateway.DownloadCacheSettingsGateway
@@ -52,7 +50,6 @@ class OtherConfigViewModelTest {
             readAloudSettingsGateway = FakeReadAloudSettingsGateway(),
             otherSettingsGateway = otherSettingsGateway,
             downloadCacheSettingsGateway = FakeDownloadCacheSettingsGateway(),
-            checkSourceSettingsGateway = FakeCheckSourceSettingsGateway(),
             directLinkSettingsGateway = FakeDirectLinkSettingsGateway(),
             localPasswordGateway = FakeLocalPasswordGateway(),
             systemGateway = FakeOtherConfigSystemGateway(),
@@ -87,18 +84,6 @@ class OtherConfigViewModelTest {
         assertEquals(1, viewModel.uiState.value.pendingMessages.size)
     }
 
-    @Test
-    fun confirmCheckSource_writesThroughGateway() = runBlocking {
-        val checkSourceGateway = FakeCheckSourceSettingsGateway()
-        val viewModel = createViewModel(checkSourceSettingsGateway = checkSourceGateway)
-
-        viewModel.onIntent(OtherConfigIntent.CheckSourceTimeoutChanged(42L))
-        viewModel.onIntent(OtherConfigIntent.ConfirmCheckSource)
-        Shadows.shadowOf(Looper.getMainLooper()).idle()
-
-        assertEquals(42_000L, checkSourceGateway.lastUpdate?.timeoutMillis)
-    }
-
     @Test
     fun clearWebViewData_emitsRestartRequest() = runBlocking {
         val viewModel = createViewModel()
@@ -153,8 +138,6 @@ class OtherConfigViewModelTest {
 
     private fun createViewModel(
         otherSettingsGateway: FakeOtherSettingsGateway = FakeOtherSettingsGateway(),
-        checkSourceSettingsGateway: FakeCheckSourceSettingsGateway =
-            FakeCheckSourceSettingsGateway(),
         directLinkSettingsGateway: FakeDirectLinkSettingsGateway =
             FakeDirectLinkSettingsGateway(),
         localPasswordGateway: FakeLocalPasswordGateway = FakeLocalPasswordGateway(),
@@ -164,7 +147,6 @@ class OtherConfigViewModelTest {
         readAloudSettingsGateway = FakeReadAloudSettingsGateway(),
         otherSettingsGateway = otherSettingsGateway,
         downloadCacheSettingsGateway = FakeDownloadCacheSettingsGateway(),
-        checkSourceSettingsGateway = checkSourceSettingsGateway,
         directLinkSettingsGateway = directLinkSettingsGateway,
         localPasswordGateway = localPasswordGateway,
         systemGateway = systemGateway,
@@ -230,20 +212,6 @@ class OtherConfigViewModelTest {
         }
     }
 
-    private class FakeCheckSourceSettingsGateway : CheckSourceSettingsGateway {
-        private val state = MutableStateFlow(CheckSourceSettings())
-        var lastUpdate: CheckSourceSettings? = null
-
-        override val currentSettings: CheckSourceSettings
-            get() = state.value
-        override val settings: Flow<CheckSourceSettings> = state
-
-        override suspend fun update(settings: CheckSourceSettings) {
-            lastUpdate = settings
-            state.value = settings
-        }
-    }
-
     private class FakeDirectLinkSettingsGateway : DirectLinkSettingsGateway {
         private val rule = DirectLinkRule(
             uploadUrl = "https://example.com",