feat(companion): add optimistic updates to EventTypeDetail screen#26935
Merged
dhairyashiil merged 2 commits intofeat/companion-auto-reload-on-savefrom Jan 16, 2026
Merged
Conversation
- Enhance useUpdateEventType hook with full optimistic update support - Add onMutate callback to update cache immediately - Add onSuccess callback to sync with server response - Add onError callback to rollback on failure - Update both eventTypes.detail(id) and eventTypes.lists() caches - Refactor handleSave in event-type-detail.tsx - Replace direct CalComAPIService.updateEventType() with useUpdateEventType hook - Replace direct CalComAPIService.createEventType() with useCreateEventType hook - Remove manual fetchEventTypeData() call after save (cache updates automatically) - Replace local saving state with mutation hooks' isPending states - Refactor handleDelete in event-type-detail.tsx - Replace direct CalComAPIService.deleteEventType() with useDeleteEventType hook This ensures the event types list updates immediately after save/delete without requiring manual refresh.
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Contributor
There was a problem hiding this comment.
2 issues found across 2 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="companion/hooks/useEventTypes.ts">
<violation number="1" location="companion/hooks/useEventTypes.ts:128">
P2: Widening `updates` to `Record<string, unknown>` removes the compile-time contract with `CreateEventTypeInput`, so callers can now send invalid payload shapes that the API will only reject at runtime. Keep the hook typed as `Partial<CreateEventTypeInput>` (cast for cache merges if needed) to preserve type safety.</violation>
</file>
<file name="companion/app/(tabs)/(event-types)/event-type-detail.tsx">
<violation number="1" location="companion/app/(tabs)/(event-types)/event-type-detail.tsx:1257">
P2: `eventTypeData` is never synced after a successful update anymore, so dirty-checking compares against stale data. After saving once, `isDirty` stays true and reverting a field back to its original value no longer triggers an update because the baseline still matches the old value.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Contributor
Devin AI is addressing Cubic AI's review feedbackNew feedback has been sent to the existing Devin session. ✅ Pushed commit |
Revert the type from Record<string, unknown> back to Partial<CreateEventTypeInput> to preserve compile-time type checking for callers. Addresses Cubic AI review feedback (confidence 9/10).
93e8d79
into
feat/companion-auto-reload-on-save
15 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR adds optimistic updates to the EventTypeDetail screen in the companion app, ensuring the event types list updates immediately after save/delete operations without requiring manual refresh.
Note: This is a stacked PR that depends on #26931 (
feat/companion-auto-reload-on-save).Changes:
Enhanced
useUpdateEventTypehook with full optimistic update support:onMutatecallback to update cache immediately before server responseonSuccesscallback to sync cache with server responseonErrorcallback to rollback cache on failureeventTypes.detail(id)andeventTypes.lists()cachesRefactored
handleSavein event-type-detail.tsx:CalComAPIService.updateEventType()withuseUpdateEventTypehookCalComAPIService.createEventType()withuseCreateEventTypehookfetchEventTypeData()call after save (cache updates automatically)Refactored
handleDeletein event-type-detail.tsx:CalComAPIService.deleteEventType()withuseDeleteEventTypehookReplaced local
savingstate with mutation hooks'isPendingstates (isUpdating || isCreating)Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
Test on iOS and Android devices/simulators
Test update flow:
Test delete flow:
Test error rollback:
Human Review Checklist
eventTypeDatalocal state is not synced after update - dirty-checking may compare against stale baseline after first save. This is a known limitation that may need follow-up work if it causes issues.Link to Devin run: https://app.devin.ai/sessions/0e35f5cdab8943dabb66fc182e4241fe
Requested by: Dhairyashil Shinde (@dhairyashiil)