Skip to content

Commit 04f655b

Browse files
committed
Remove beta to prod data migration
1 parent 627ef6b commit 04f655b

4 files changed

Lines changed: 1 addition & 52 deletions

File tree

app/src/main/kotlin/com/darkrockstudios/app/securecamera/SnapSafeApplication.kt

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ package com.darkrockstudios.app.securecamera
22

33
import android.app.Application
44
import com.darkrockstudios.app.securecamera.camera.SecureImageRepository
5-
import com.darkrockstudios.app.securecamera.preferences.AppPreferencesDataSource
6-
import com.darkrockstudios.app.securecamera.usecases.SecurityResetUseCase
7-
import kotlinx.coroutines.flow.first
8-
import kotlinx.coroutines.runBlocking
95
import org.koin.android.ext.koin.androidContext
106
import org.koin.android.ext.koin.androidLogger
117
import org.koin.core.component.KoinComponent
@@ -17,8 +13,6 @@ import timber.log.Timber
1713

1814
open class SnapSafeApplication : Application(), KoinComponent {
1915
private val imageManager by inject<SecureImageRepository>()
20-
private val preferences by inject<AppPreferencesDataSource>()
21-
private val securityReset by inject<SecurityResetUseCase>()
2216

2317
override fun onCreate() {
2418
super.onCreate()
@@ -34,8 +28,6 @@ open class SnapSafeApplication : Application(), KoinComponent {
3428
androidContext(this@SnapSafeApplication)
3529
modules(appModule, flavorModule())
3630
}
37-
38-
handleMigrationFromBeta()
3931
}
4032

4133
open fun flavorModule(): Module = module { }
@@ -49,19 +41,4 @@ open class SnapSafeApplication : Application(), KoinComponent {
4941
super.onLowMemory()
5042
imageManager.thumbnailCache.clear()
5143
}
52-
53-
// DELETE ME after a few versions
54-
private fun handleMigrationFromBeta() {
55-
runBlocking {
56-
val intoComplete = (preferences.hasCompletedIntro.first() == true)
57-
val isProdReady = (preferences.isProdReady.first() == true)
58-
val wasInBeta = intoComplete && !isProdReady
59-
if (wasInBeta) {
60-
securityReset.reset()
61-
preferences.markProdReady()
62-
} else if (!isProdReady) {
63-
preferences.markProdReady()
64-
}
65-
}
66-
}
6744
}

app/src/main/kotlin/com/darkrockstudios/app/securecamera/preferences/AppPreferencesDataSource.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ interface AppPreferencesDataSource {
77
/**
88
* Check if the user has completed the introduction
99
*/
10-
val hasCompletedIntro: Flow<Boolean?> // DELETE ME after beta migration is over
11-
val isProdReady: Flow<Boolean?>
10+
val hasCompletedIntro: Flow<Boolean?>
1211

1312
/**
1413
* Get the sanitized file name preference
@@ -30,9 +29,6 @@ interface AppPreferencesDataSource {
3029
suspend fun getCipherKey(): String
3130
suspend fun getCipheredPin(): String?
3231

33-
// DELETE ME after beta migration is over
34-
suspend fun markProdReady()
35-
3632
/**
3733
* Set the introduction completion status
3834
*/

app/src/main/kotlin/com/darkrockstudios/app/securecamera/preferences/AppPreferencesDataSourceImpl.kt

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class AppPreferencesDataSourceImpl(
4040
private val SESSION_TIMEOUT = stringPreferencesKey("session_timeout")
4141
private val SYMMETRIC_CIPHER_KEY = stringPreferencesKey("symmetric_cipher_key")
4242
private val SCHEME_CONFIG_KEY = stringPreferencesKey("scheme_config")
43-
private val IS_PROD_READY = booleanPreferencesKey("is_prod_ready")
4443

4544
val SESSION_TIMEOUT_1_MIN = 1.minutes.inWholeMilliseconds
4645
val SESSION_TIMEOUT_5_MIN = 5.minutes.inWholeMilliseconds
@@ -74,19 +73,6 @@ class AppPreferencesDataSourceImpl(
7473
preferences[HAS_COMPLETED_INTRO] ?: false
7574
}
7675

77-
// DELETE ME after beta migration is over
78-
override val isProdReady: Flow<Boolean?> = dataStore.data
79-
.map { preferences ->
80-
preferences[IS_PROD_READY] ?: false
81-
}
82-
83-
// DELETE ME after beta migration is over
84-
override suspend fun markProdReady() {
85-
dataStore.edit { preferences ->
86-
preferences[IS_PROD_READY] = true
87-
}
88-
}
89-
9076
/**
9177
* Get the sanitized file name preference
9278
*/
@@ -191,7 +177,6 @@ class AppPreferencesDataSourceImpl(
191177
dataStore.edit { preferences ->
192178
preferences.clear()
193179
}
194-
markProdReady()
195180
}
196181

197182
/**

app/src/test/kotlin/com/darkrockstudios/app/securecamera/preferences/AppPreferencesDataSourceTest.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,6 @@ class AppPreferencesDataSourceTest {
4141
assertEquals(false, sut.hasCompletedIntro.first())
4242
}
4343

44-
@Test
45-
fun `isProdReady defaults false, markProdReady true`() = runTest {
46-
val sut = newSut()
47-
assertEquals(false, sut.isProdReady.first())
48-
sut.markProdReady()
49-
assertEquals(true, sut.isProdReady.first())
50-
}
51-
5244
@Test
5345
fun `sanitize flags default to true and are settable`() = runTest {
5446
val sut = newSut()
@@ -140,7 +132,6 @@ class AppPreferencesDataSourceTest {
140132

141133
// Verify defaults/cleared
142134
assertEquals(false, sut.hasCompletedIntro.first())
143-
assertEquals(true, sut.isProdReady.first())
144135
assertEquals(true, sut.sanitizeFileName.first())
145136
assertEquals(true, sut.sanitizeMetadata.first())
146137
assertEquals(0, sut.getFailedPinAttempts())

0 commit comments

Comments
 (0)