codelab-android-datastore
codelab-android-datastore copied to clipboard
[Pref DataStore] Deadline & Priority switches go in infinite loop
Issue :: When both deadline and priority are selected, leaving the app and reopening, makes deadline & priority switches go in infinite loop Steps to reproduce:
- Launch app from preferences_datastore branch
- Select both deadline and priority option
- exit the app by back pressing
- launch the app again
- deadline and priority switches go in infinite loop
Why:: After reopening, updateSort -> enableSortByPriority -> SortOrder.BY_PRIORITY -> updateSort -> enableSortByDeadline -> SortOrder.BY_DEADLINE_AND_PRIORITY -> enableSortByPriority -> SortOrder.BY_PRIORITY -> updateSort -> ♾
Solution :: Inside enableSortByPriority / enableSortByDeadline mtds, check if the argument is enable and SortOrder is BY_DEADLINE_AND_PRIORITY, return from the mtds.