@@ -76,6 +76,8 @@ class UserPreferencesRepository private constructor(context: Context) {
76
76
SortOrder .valueOf(
77
77
preferences[Keys .SORT_ORDER_KEY ] ? : SortOrder .NONE .name
78
78
)
79
+
80
+ // Get our show completed value, defaulting to false if not set:
79
81
val showCompleted = preferences[Keys .SHOW_COMPLETED_KEY ] ? : false
80
82
UserPreferences (showCompleted, sortOrder)
81
83
}
@@ -86,10 +88,11 @@ class UserPreferencesRepository private constructor(context: Context) {
86
88
suspend fun enableSortByDeadline (enable : Boolean ) {
87
89
// updateData handles data transactionally, ensuring that if the sort is updated at the same
88
90
// time from another thread, we won't have conflicts
89
- dataStore.edit { prefs ->
90
- val currentOrder = prefs[Keys .SORT_ORDER_KEY ]?.let { SortOrder .valueOf(it) }
91
+ dataStore.edit { preferences ->
92
+ val currentOrder =
93
+ preferences[Keys .SORT_ORDER_KEY ]?.let { SortOrder .valueOf(it) }
91
94
92
- val newSortOrder =
95
+ val newSortOrder =
93
96
if (enable) {
94
97
if (currentOrder == SortOrder .BY_PRIORITY ) {
95
98
SortOrder .BY_DEADLINE_AND_PRIORITY
@@ -104,7 +107,7 @@ class UserPreferencesRepository private constructor(context: Context) {
104
107
}
105
108
}
106
109
107
- prefs [Keys .SORT_ORDER_KEY ] = newSortOrder.name
110
+ preferences [Keys .SORT_ORDER_KEY ] = newSortOrder.name
108
111
}
109
112
}
110
113
@@ -137,8 +140,8 @@ class UserPreferencesRepository private constructor(context: Context) {
137
140
}
138
141
139
142
suspend fun updateShowCompleted (showCompleted : Boolean ) {
140
- dataStore.edit { prefs ->
141
- prefs [Keys .SHOW_COMPLETED_KEY ] = showCompleted
143
+ dataStore.edit { preferences ->
144
+ preferences [Keys .SHOW_COMPLETED_KEY ] = showCompleted
142
145
}
143
146
}
144
147
0 commit comments