Skip to content

Conversation

@felixevers
Copy link
Member

  • Add priority field (P1-P4) with color coding similar to Todoist
  • Add estimated_time field (in minutes) for task duration estimation
  • Both fields are optional
  • Update backend: model, migration, GraphQL types, resolvers
  • Update frontend: UI components, queries, display with color coding
  • Priority colors: P1 (red), P2 (orange), P3 (yellow), P4 (blue)

Which issues does this pull request close?

closes #30 #31

[OPTIONAL] Give testing instructions to reviewers

- Add priority field (P1-P4) with color coding similar to Todoist
- Add estimated_time field (in minutes) for task duration estimation
- Both fields are optional
- Update backend: model, migration, GraphQL types, resolvers
- Update frontend: UI components, queries, display with color coding
- Priority colors: P1 (red), P2 (orange), P3 (yellow), P4 (blue)

Implements #30 and #31
- Include priority and estimatedTime in UpdateTask mutation response
- Include current priority value when persisting estimatedTime changes
- Prevents priority from being reset when updating estimated time
- Update formData directly from mutation response instead of relying on refetch
- Remove refetch() call from persistChanges to avoid race conditions
- Make useEffect smarter to only update when data actually changes
- Prevents input fields from resetting after updates
- Fix null/undefined checks in TaskDetailView useEffect
- Remove trailing spaces
- Fix React Hook dependency array
- All linting errors resolved
Root cause: refetchInterval and useEffect were overwriting local edits

Solution:
- Track dirty fields with useRef to prevent overwriting fields being edited
- Use React Query cache updates instead of refetch() to avoid race conditions
- Update cache directly from mutation responses
- Only merge server data with local state, preserving dirty fields
- Mark fields as dirty when user starts editing
- Clear dirty flags after successful mutation

This ensures:
- Every field update persists immediately to backend
- Form state never resets when moving between fields
- Server updates don't overwrite local edits in progress
- Add patient field to UpdateTask mutation response
- Fix cache update to merge instead of replace, preserving all fields
- Ensure formData preserves patientId when updating other fields
- Fix TypeScript types for cache update function

This fixes the issue where patient name disappeared when updating priority
…validation

Root cause: Cache invalidation and refetchInterval were overwriting recently updated fields

Solution:
- Track field update timestamps with fieldUpdateTimestampsRef
- Add 5-second grace period to preserve recently updated fields
- Enhance shouldPreserveField to check both dirty flags and timestamps
- Explicitly preserve priority and estimatedTime in cache merge (even if null)
- Set timestamps before mutation and in mutation onSuccess

This prevents:
- Priority/estimatedTime reset when queryClient.invalidateQueries() is called
- Fields being overwritten by refetchInterval (3s) after updates
- Race conditions between mutations and refetches
…to null

Root cause: When optional fields are null, server returns null and we overwrite form state

Solution:
- Always check shouldPreserveField before overwriting priority/estimatedTime
- Preserve fields in final return statement even when hasDirtyFields is false
- Improve cache merge to explicitly check for field presence
- Handle null values correctly in comparisons

This ensures:
- Priority/estimatedTime never reset to null after being set
- Grace period protection works even when server returns null
- Fields are preserved during refetch/cache invalidation cycles
…skInput

Root cause: Optional fields defaulted to None, making it impossible to distinguish
between 'field not provided' and 'field set to null'

Solution:
- Change priority and estimated_time defaults to strawberry.UNSET in UpdateTaskInput
- This allows backend to correctly handle:
  - Field not provided: strawberry.UNSET -> don't update
  - Field set to null: None -> update to null
  - Field set to value: TaskPriority/int -> update to value

This ensures:
- Priority/estimatedTime persist correctly when set
- Fields can be explicitly cleared by setting to null
- Other fields can be updated without affecting priority/estimatedTime
@felixevers felixevers merged commit d611d64 into main Dec 28, 2025
18 checks passed
@felixevers felixevers deleted the feat/extent-task branch December 28, 2025 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

prioritization of tasks

2 participants