@@ -57,41 +57,43 @@ class DuckDuckGoWebLocalStorageManager @Inject constructor(
57
57
private var matchingRegex = emptyList<String >()
58
58
59
59
override fun clearWebLocalStorage () = runBlocking {
60
- val settings = androidBrowserConfigFeature.webLocalStorage().getSettings()
61
- val webLocalStorageSettings = webLocalStorageSettingsJsonParser.parseJson(settings)
60
+ withContext(dispatcherProvider.io()) {
61
+ val settings = androidBrowserConfigFeature.webLocalStorage().getSettings()
62
+ val webLocalStorageSettings = webLocalStorageSettingsJsonParser.parseJson(settings)
62
63
63
- val fireproofedDomains = if (androidBrowserConfigFeature.fireproofedWebLocalStorage().isEnabled()) {
64
- withContext(dispatcherProvider.io()) {
65
- fireproofWebsiteRepository.fireproofWebsitesSync().map { it.domain }
64
+ val fireproofedDomains = if (androidBrowserConfigFeature.fireproofedWebLocalStorage().isEnabled()) {
65
+ withContext(dispatcherProvider.io()) {
66
+ fireproofWebsiteRepository.fireproofWebsitesSync().map { it.domain }
67
+ }
68
+ } else {
69
+ emptyList()
66
70
}
67
- } else {
68
- emptyList()
69
- }
70
71
71
- domains = webLocalStorageSettings.domains.list + fireproofedDomains
72
- keysToDelete = webLocalStorageSettings.keysToDelete.list
73
- matchingRegex = webLocalStorageSettings.matchingRegex.list
72
+ domains = webLocalStorageSettings.domains.list + fireproofedDomains
73
+ keysToDelete = webLocalStorageSettings.keysToDelete.list
74
+ matchingRegex = webLocalStorageSettings.matchingRegex.list
74
75
75
- logcat { " WebLocalStorageManager: Allowed domains: $domains " }
76
- logcat { " WebLocalStorageManager: Keys to delete: $keysToDelete " }
77
- logcat { " WebLocalStorageManager: Matching regex: $matchingRegex " }
76
+ logcat { " WebLocalStorageManager: Allowed domains: $domains " }
77
+ logcat { " WebLocalStorageManager: Keys to delete: $keysToDelete " }
78
+ logcat { " WebLocalStorageManager: Matching regex: $matchingRegex " }
78
79
79
- val db = databaseProvider.get()
80
- db.iterator().use { iterator ->
81
- iterator.seekToFirst()
80
+ val db = databaseProvider.get()
81
+ db.iterator().use { iterator ->
82
+ iterator.seekToFirst()
82
83
83
- while (iterator.hasNext()) {
84
- val entry = iterator.next()
85
- val key = String (entry.key, StandardCharsets .UTF_8 )
84
+ while (iterator.hasNext()) {
85
+ val entry = iterator.next()
86
+ val key = String (entry.key, StandardCharsets .UTF_8 )
86
87
87
- val domainForMatchingAllowedKey = getDomainForMatchingAllowedKey(key)
88
- if (domainForMatchingAllowedKey == null ) {
89
- db.delete(entry.key)
90
- logcat { " WebLocalStorageManager: Deleted key: $key " }
91
- } else if (settingsDataStore.clearDuckAiData && domainForMatchingAllowedKey == DUCKDUCKGO_DOMAIN ) {
92
- if (keysToDelete.any { key.endsWith(it) }) {
88
+ val domainForMatchingAllowedKey = getDomainForMatchingAllowedKey(key)
89
+ if (domainForMatchingAllowedKey == null ) {
93
90
db.delete(entry.key)
94
91
logcat { " WebLocalStorageManager: Deleted key: $key " }
92
+ } else if (settingsDataStore.clearDuckAiData && domainForMatchingAllowedKey == DUCKDUCKGO_DOMAIN ) {
93
+ if (keysToDelete.any { key.endsWith(it) }) {
94
+ db.delete(entry.key)
95
+ logcat { " WebLocalStorageManager: Deleted key: $key " }
96
+ }
95
97
}
96
98
}
97
99
}
0 commit comments