Conversation
- Add taskIndentLevels storage methods to SharedPreferencesUtil - Load indent levels from SharedPreferences on ActionItemsPage init - Save indent levels when incrementing or decrementing indentation - Ensures task hierarchy/nesting survives app restart Co-authored-by: Nik Shevchenko <[email protected]>
|
Cursor Agent can help with this pull request. Just |
There was a problem hiding this comment.
Code Review
This pull request successfully implements persistence for task indentation levels. The changes are well-contained and follow existing patterns for using SharedPreferences. I've identified two areas for improvement: one is to add logging for deserialization errors to aid in debugging, and the other is to implement a mechanism for cleaning up stale indentation data for deleted tasks to prevent storage bloat and memory leaks. Overall, a good addition to persist UI state.
| } catch (e) { | ||
| return {}; | ||
| } |
There was a problem hiding this comment.
The catch block silently fails and returns an empty map. While this prevents the app from crashing, it hides potential issues with data serialization or corruption. It would be beneficial to log the error, similar to how it's done in the customSttConfig getter in this same file. This helps with debugging if users report issues with their settings not being persisted correctly.
} catch (e) {
Logger.debug('Error parsing taskIndentLevels: $e');
return {};
}| void _loadIndentLevels() { | ||
| final savedLevels = SharedPreferencesUtil().taskIndentLevels; | ||
| setState(() { | ||
| _indentLevels | ||
| ..clear() | ||
| ..addAll(savedLevels); | ||
| }); | ||
| } |
There was a problem hiding this comment.
The current implementation for persisting indent levels does not account for task deletion. When a task is deleted, its indent level remains in SharedPreferences, leading to accumulation of stale data over time. This causes storage bloat and a minor memory leak in the _indentLevels map.
A pruning mechanism should be implemented to remove indent levels for tasks that no longer exist. This could be done when tasks are deleted (e.g., in _deleteTask), or periodically by comparing the keys in _indentLevels with the current task IDs after they are fetched. A similar cleanup pattern is used in _pruneTaskGoalLinks.
Fix task indentation persistence in the action items list.
This PR ensures that when a user indents or dedents a task, its hierarchical state is saved to persistent storage and correctly restored upon app restart.