Skip to content

Commit 2a234c6

Browse files
committed
add prefs clear on full restore
1 parent ec85325 commit 2a234c6

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

data_local/src/main/java/com/example/util/simpletimetracker/data_local/backup/BackupPartialRepoImpl.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ class BackupPartialRepoImpl @Inject constructor(
309309
successCodeMessage = null,
310310
errorCodeMessage = R.string.settings_file_open_error,
311311
clearData = false,
312+
clearPrefs = false,
312313
migrateTags = {
313314
tags += backupRepo.migrateTags(
314315
types = types,

data_local/src/main/java/com/example/util/simpletimetracker/data_local/backup/BackupRepoImpl.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import java.io.InputStreamReader
6161
import javax.inject.Inject
6262
import javax.inject.Singleton
6363
import androidx.core.net.toUri
64+
import com.example.util.simpletimetracker.domain.prefs.interactor.PrefsInteractor
6465

6566
/**
6667
* Do not change backup parts order, always add new to the end.
@@ -87,6 +88,7 @@ class BackupRepoImpl @Inject constructor(
8788
private val complexRuleRepo: ComplexRuleRepo,
8889
private val recordShortcutRepo: RecordShortcutRepo,
8990
private val clearDataInteractor: ClearDataInteractor,
91+
private val prefsInteractor: PrefsInteractor,
9092
private val resourceRepo: ResourceRepo,
9193
private val daysOfWeekDataLocalMapper: DaysOfWeekDataLocalMapper,
9294
private val backupPrefsRepo: BackupPrefsRepo,
@@ -206,6 +208,7 @@ class BackupRepoImpl @Inject constructor(
206208
successCodeMessage = R.string.message_backup_restored,
207209
errorCodeMessage = R.string.message_restore_error,
208210
clearData = true,
211+
clearPrefs = restoreSettings,
209212
migrateTags = {
210213
migrateTags(
211214
types = recordTypeRepo.getAll(),
@@ -242,6 +245,7 @@ class BackupRepoImpl @Inject constructor(
242245
@StringRes successCodeMessage: Int?,
243246
@StringRes errorCodeMessage: Int,
244247
clearData: Boolean,
248+
clearPrefs: Boolean,
245249
migrateTags: suspend (MutableList<Pair<RecordTag, Long>>) -> Unit,
246250
dataHandler: DataHandler,
247251
): ResultCode = withContext(Dispatchers.IO) {
@@ -262,6 +266,7 @@ class BackupRepoImpl @Inject constructor(
262266
if (line != BACKUP_IDENTIFICATION) return@withContext errorCode
263267

264268
if (clearData) clearDataInteractor.execute()
269+
if (clearPrefs) prefsInteractor.clear()
265270

266271
// List of tag to related type id.
267272
val tagsMigrationData: MutableList<Pair<RecordTag, Long>> = mutableListOf()

0 commit comments

Comments
 (0)