Commit 2059f3ae authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Only delete user defined rules with the clear button

parent 2579236d
......@@ -117,7 +117,7 @@ class DnsRuleActivity : BaseActivity() {
getString(R.string.dialog_clearuserrules_title),
getString(R.string.dialog_clearuserrules_message),
getString(R.string.all_yes) to { dialog, _ ->
getDatabase().dnsRuleRepository().deleteAllAsync()
getDatabase().dnsRuleRepository().deleteAllUserRulesAsync()
dialog.dismiss()
}, getString(R.string.all_no) to { dialog, _ ->
dialog.dismiss()
......
......@@ -30,8 +30,8 @@ import org.minidns.record.Record
@TypeConverters(DnsTypeConverter::class)
interface DnsRuleDao {
@Query("DELETE FROM DnsRule")
fun deleteAll()
@Query("DELETE FROM DnsRule WHERE importedFrom IS NULL")
fun deleteAllUserRules()
@Query("UPDATE DnsRule SET stagingType=1 WHERE importedFrom IS NOT NULL")
fun markNonUserRulesForDeletion()
......
......@@ -27,9 +27,9 @@ import kotlinx.coroutines.launch
*/
class DnsRuleRepository(val dnsRuleDao: DnsRuleDao) {
fun deleteAllAsync(coroutineScope: CoroutineScope = GlobalScope) {
fun deleteAllUserRulesAsync(coroutineScope: CoroutineScope = GlobalScope) {
coroutineScope.launch {
dnsRuleDao.deleteAll()
dnsRuleDao.deleteAllUserRules()
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment