fetch Tasks
Fetches the user's tasks, optionally filtered by category.
This function retrieves tasks belonging to the connected user. If a categoryId is specified, only tasks in that category will be fetched. If null, tasks from all categories are retrieved.
The result is returned as a RainbowResult containing a map where the key is a TaskCategory and the value is a list of Task objects within that category.
Note: If you are already observing the tasks property (e.g. via StateFlow), you may not need to call this method manually, unless you want to force a refresh or handle the result explicitly.
Example usage:
val result = fetchTasks()
if (result.isSuccess) {
val tasksByCategory = result.getOrThrow()
// Use the tasks grouped by category
} else {
val error = result.failureOrNull()
// Handle failure
}Return
A RainbowResult containing a Map of TaskCategory to lists of Tasks on success, or a Failure on error.
Parameters
Optional ID of the category to filter tasks by. If null, all tasks are fetched.