Conversation
- Add taskIndentLevels getter/setter to SharedPreferencesUtil for persistence - Load saved indent levels on ActionItemsPage init - Save indent levels when user swipes to indent/unindent tasks - Follows existing pattern for taskCategoryOrder and taskGoalLinks Fixes task indentation state not persisting after app restart Co-authored-by: Nik Shevchenko <kodjima33@users.noreply.github.com>
|
Cursor Agent can help with this pull request. Just |
There was a problem hiding this comment.
Code Review
This pull request adds persistence for task indentation levels, which is a great enhancement for user experience. The implementation correctly uses SharedPreferences to store and retrieve the indent levels. However, I've identified a high-severity issue where the indent level for a deleted task is not removed from storage, leading to an accumulation of stale data over time. My review includes a detailed comment on how to address this data leak.
| void _saveTaskIndentLevels() { | ||
| SharedPreferencesUtil().taskIndentLevels = Map<String, int>.from(_indentLevels); | ||
| } |
There was a problem hiding this comment.
The current implementation persists indent levels but doesn't handle cleaning up this data when a task is deleted. This will lead to stale data for deleted tasks accumulating in SharedPreferences over time.
To fix this, you should ensure that when a task is deleted, its corresponding entry in _indentLevels is also removed and the map is re-saved.
Since task deletion can be initiated from different places (e.g., swipe-to-delete on this page or from the ActionItemFormSheet), you'll need to handle cleanup in each case. For swipe-to-delete, you could modify the _deleteTask method:
Future<void> _deleteTask(ActionItemWithMetadata item) async {
HapticFeedback.mediumImpact();
final provider = Provider.of<ActionItemsProvider>(context, listen: false);
final success = await provider.deleteActionItem(item);
if (success && mounted) {
if (_indentLevels.remove(item.id) != null) {
_saveTaskIndentLevels();
}
}
}A similar approach would be needed for deletions from the edit sheet, likely by passing a callback.
| void _saveTaskIndentLevels() { | |
| SharedPreferencesUtil().taskIndentLevels = Map<String, int>.from(_indentLevels); | |
| } | |
| Future<void> _deleteTask(ActionItemWithMetadata item) async { | |
| HapticFeedback.mediumImpact(); | |
| final provider = Provider.of<ActionItemsProvider>(context, listen: false); | |
| final success = await provider.deleteActionItem(item); | |
| if (success && mounted) { | |
| if (_indentLevels.remove(item.id) != null) { | |
| _saveTaskIndentLevels(); | |
| } | |
| } | |
| } |
|
Closing this stale draft — no activity in 3+ days. Feel free to reopen when it's ready for review. |
|
Hey @kodjima33 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! 💜 |
Persist task indent levels across app restarts to ensure indentation state is restored.