Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
karlenDimla committed Oct 23, 2024
1 parent f9d7a42 commit a064819
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package com.duckduckgo.networkprotection.impl.autoexclude

import com.duckduckgo.di.scopes.ActivityScope
import com.duckduckgo.networkprotection.impl.autoexclude.AutoExcludePrompt.Trigger
import com.duckduckgo.networkprotection.impl.autoexclude.AutoExcludePrompt.Trigger.NEW_FLAGGED_APP
import com.duckduckgo.networkprotection.impl.autoexclude.AutoExcludePrompt.Trigger.NEW_INCOMPATIBLE_APP_FOUND
import com.duckduckgo.networkprotection.store.NetPExclusionListRepository
import com.squareup.anvil.annotations.ContributesBinding
import javax.inject.Inject
Expand All @@ -27,7 +27,7 @@ interface AutoExcludePrompt {
suspend fun getAppsForPrompt(trigger: Trigger): List<VpnIncompatibleApp>

enum class Trigger {
NEW_FLAGGED_APP,
NEW_INCOMPATIBLE_APP_FOUND,
INCOMPATIBLE_APP_MANUALLY_EXCLUDED,
}
}
Expand All @@ -38,7 +38,7 @@ class RealAutoExcludePrompt @Inject constructor(
private val autoExcludeAppsRepository: AutoExcludeAppsRepository,
) : AutoExcludePrompt {
override suspend fun getAppsForPrompt(trigger: Trigger): List<VpnIncompatibleApp> {
return if (trigger == NEW_FLAGGED_APP) {
return if (trigger == NEW_INCOMPATIBLE_APP_FOUND) {
getFlaggedAppsForPrompt().also {
autoExcludeAppsRepository.markAppsAsShown(it)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import com.duckduckgo.networkprotection.api.NetworkProtectionState
import com.duckduckgo.networkprotection.impl.NetPVpnFeature
import com.duckduckgo.networkprotection.impl.VpnRemoteFeatures
import com.duckduckgo.networkprotection.impl.autoexclude.AutoExcludePrompt
import com.duckduckgo.networkprotection.impl.autoexclude.AutoExcludePrompt.Trigger.NEW_FLAGGED_APP
import com.duckduckgo.networkprotection.impl.autoexclude.AutoExcludePrompt.Trigger.NEW_INCOMPATIBLE_APP_FOUND
import com.duckduckgo.networkprotection.impl.autoexclude.VpnIncompatibleApp
import com.duckduckgo.networkprotection.impl.configuration.WgTunnelConfig
import com.duckduckgo.networkprotection.impl.configuration.asServerDetails
Expand Down Expand Up @@ -194,7 +194,7 @@ class NetworkProtectionManagementViewModel @Inject constructor(
if (networkProtectionState.isRunning() &&
!localConfig.autoExcludeBrokenApps().isEnabled()
) {
autoExcludePrompt.getAppsForPrompt(NEW_FLAGGED_APP).also {
autoExcludePrompt.getAppsForPrompt(NEW_INCOMPATIBLE_APP_FOUND).also {
if (it.isNotEmpty()) {
sendCommand(ShowAutoExcludeDialog(it))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.duckduckgo.networkprotection.impl.autoexclude

import com.duckduckgo.networkprotection.impl.autoexclude.AutoExcludePrompt.Trigger.NEW_FLAGGED_APP
import com.duckduckgo.networkprotection.impl.autoexclude.AutoExcludePrompt.Trigger.NEW_INCOMPATIBLE_APP_FOUND
import com.duckduckgo.networkprotection.store.NetPExclusionListRepository
import com.duckduckgo.networkprotection.store.db.NetPManuallyExcludedApp
import kotlinx.coroutines.test.runTest
Expand Down Expand Up @@ -44,7 +44,7 @@ class RealAutoExcludePromptTest {
VpnIncompatibleApp("test2"),
),
)
val result = autoExcludePrompt.getAppsForPrompt(NEW_FLAGGED_APP)
val result = autoExcludePrompt.getAppsForPrompt(NEW_INCOMPATIBLE_APP_FOUND)

assertTrue(result.contains(VpnIncompatibleApp("test1")))
assertFalse(result.contains(VpnIncompatibleApp("test2")))
Expand All @@ -60,7 +60,7 @@ class RealAutoExcludePromptTest {
VpnIncompatibleApp("test2"),
),
)
val result = autoExcludePrompt.getAppsForPrompt(NEW_FLAGGED_APP)
val result = autoExcludePrompt.getAppsForPrompt(NEW_INCOMPATIBLE_APP_FOUND)

assertTrue(result.contains(VpnIncompatibleApp("test1")))
assertTrue(result.contains(VpnIncompatibleApp("test2")))
Expand All @@ -71,7 +71,7 @@ class RealAutoExcludePromptTest {
whenever(netPExclusionListRepository.getManualAppExclusionList()).thenReturn(emptyList())
whenever(autoExcludeAppsRepository.getAppsForAutoExcludePrompt()).thenReturn(emptyList())

val result = autoExcludePrompt.getAppsForPrompt(NEW_FLAGGED_APP)
val result = autoExcludePrompt.getAppsForPrompt(NEW_INCOMPATIBLE_APP_FOUND)

assertTrue(result.isEmpty())
}
Expand Down

0 comments on commit a064819

Please sign in to comment.