Say so when deleting or reordering views can't be stored (#59)
Views stored by another version are left alone, and the last used view and start screen no longer reset when the delete didn't happen. A view's block changes in one edit.
This commit is contained in:
1 parent
56f81d9c2e
commit
710cafff3a
5 files changed
+86
-10
No files matched your search
@@ -114,4 +114,21 @@ class ViewPrefsTest {
|
||||
assertThat(prefs.saveView(newView(0, "B"))).isNull()
|
||||
assertThat(store.data.value[ViewsMigration.KEY]).isEqualTo("v2\nview|1|x|HOME|1|")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `views change in one edit, and not at all when another version's`() = runBlocking<Unit> {
|
||||
val id = prefs.saveView(newView(0, "A"))!!
|
||||
assertThat(prefs.updateView(id) { it.copy(name = "B") }).isTrue()
|
||||
assertThat(prefs.views.first()[1].name).isEqualTo("B")
|
||||
assertThat(prefs.updateView(99) { it }).isFalse()
|
||||
assertThat(prefs.storedViewIds.first()).containsExactly(View.HOME_ID, id)
|
||||
|
||||
val store = MemoryDataStore()
|
||||
val other = SettingsPrefs(store, ProviderResolver(NoProviders))
|
||||
store.data.value = androidx.datastore.preferences.core.preferencesOf(ViewsMigration.KEY to "v2\nview|5|x|HOME|1|")
|
||||
assertThat(other.deleteView(5)).isFalse()
|
||||
assertThat(other.reorderViews(listOf(5L))).isFalse()
|
||||
assertThat(other.updateView(View.HOME_ID) { it }).isFalse()
|
||||
assertThat(other.storedViewIds.first()).isNull()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user