Skip to content

Commit

Permalink
fix card order reset after selecting default types
Browse files Browse the repository at this point in the history
  • Loading branch information
Razeeman committed Aug 25, 2024
1 parent 682ed77 commit f5360f7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class PrefsRepoImpl @Inject constructor(
KEY_CARD_ORDER, 0, // Default to name sort.
)

override val hasCardOrder: Boolean
get() = prefs.contains(KEY_CARD_ORDER)

override var categoryOrder: Int by prefs.delegate(
KEY_CATEGORY_ORDER, 0, // Default to name sort.
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ class PrefsInteractor @Inject constructor(
prefsRepo.cardOrder = mapFromCardOrder(cardOrder)
}

suspend fun hasCardOrder(): Boolean = withContext(Dispatchers.IO) {
prefsRepo.hasCardOrder
}

suspend fun getCategoryOrder(): CardOrder = withContext(Dispatchers.IO) {
mapToCardOrder(prefsRepo.categoryOrder)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface PrefsRepo {
var chartFilterType: Int

var cardOrder: Int
val hasCardOrder: Boolean
var categoryOrder: Int
var tagOrder: Int

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ class DefaultTypesSelectionViewModel @Inject constructor(
// Remove ids for correct adding in database.
recordTypeInteractor.add(it.copy(id = 0))
}
prefsInteractor.setCardOrder(CardOrder.COLOR)
if (!prefsInteractor.hasCardOrder()) {
prefsInteractor.setCardOrder(CardOrder.COLOR)
}
wearInteractor.update()
close.set(Unit)
}
Expand Down

0 comments on commit f5360f7

Please sign in to comment.