android / android/codelab-android-datastore
[Pref DataStore] Deadline & Priority switches go in infinite loop
- Dominant language
- Kotlin
- Stars
- 240
- Forks
- 113
- PR merge metrics
- No merged PRs in 30d
Description
**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.
Contributor guide
Research direction
Start in the preferences_datastore branch by tracing the updateSort, enableSortByPriority, and enableSortByDeadline methods described in the issue. Reproduce the restart flow with both switches enabled, then verify that reopening the app no longer cycles between the sort updates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100