Repository navigation
Conversation
Shared setup for moving console pages from fetch-in-effect to TanStack
Query, so each area can migrate on its own branch:
- one QueryClient for the app, provided in App.tsx; failed mutations
are shown in a toast by the mutation cache, so no save fails silently
- unwrap() turns an openapi-fetch { error } into a thrown ApiError,
since openapi-fetch never throws on HTTP errors; problemDetail reads it
- useProjectLocales / projectLocalesQuery: the project's locales as one
cached query with the API's maximum page size
…s error useResolver committed whichever request settled last and only logged failures, so a slow response for old params could overwrite newer data and callers could not tell a failed load from a pending one. Only the latest call now commits, and the error is a new last tuple element. SearchTable gains optional isLoading/isError/onRetry props so a failed load can show an error row with Retry instead of an endless skeleton, and a new search drops the cursor so it starts from the first page.
openapi-fetch returns a rejected PUT instead of throwing, so creating a scheduled item the server refused showed the success toast, closed the dialog and reset the form. The create is now a mutation over unwrap that keeps the dialog and input on failure. The list and schedule schemas load through queries keyed by page and search, so a stale response can't win, and a failed load shows an error with Retry instead of an endless skeleton or raw ids. The file is split into queries, the create dialog, the action dialogs and the expanded row.
InlineEdit and DateTimeEdit awaited onSave without a catch, so a failed save became an unhandled rejection. They now keep the editor open with the user's value; callers still report the error themselves.
Removing a sender address ignored the openapi-fetch error, so a refused DELETE closed the confirmation and left the row without a word; it is now a mutation that reports the failure and keeps the confirmation. The integration list, the sender picker and the inbox rows share queries under ["projects", id, "sender-identities"], so a change in one place shows everywhere and expanding a row no longer refetches the sender. Failed loads show an error with Retry instead of an endless skeleton or "no addresses", and the picker says the selected sender is loading or failed to load instead of showing the placeholder.
The media manager swallowed upload and delete errors and showed "no images" when the list failed to load. Uploads and deletes are now mutations whose failures are reported, the list is a query that shows an error with Retry, and both refresh the list on success.
A failed inbox load left the table on its skeleton forever, and the debounced search and status/page changes had no guard against a slower, older response. The list is now a query keyed by page, search and status, with an error row and Retry. Creating and updating messages are mutations, so refused requests are reported with the server's detail. A refused reschedule now keeps the date editor open instead of closing it as if it saved. The file is split into queries, the row and the create dialog.
…ion preview - The sidebar loads the project and organization lists through queries keyed ["projects", "list"] and ["organizations", "list"], so pages that create or rename one can invalidate them and the switcher shows the change. A failed load offers a retry in the switcher instead of silently listing nothing. - The user import dialog shows a failed import instead of leaving an unhandled rejection, unless the mutation cache already reported it. - The action preview loads through a query keyed by action type, so a quick switch can't show the wrong preview, and a failed load says so with Retry instead of the preview silently disappearing. - Remove provider/select.tsx, which nothing imports.
The sender picker's providers query shares its key with the settings pages' providers list. It fetched only the API's default first page, so whichever page loaded first decided how many providers the other saw: after opening the picker, Integrations could show at most 20. Page through all providers, as the settings query does.
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.
Why
Components used across the console hid failures:
Changes
Infrastructure (backwards compatible; no caller has to change):
useResolver(hooks.ts):InlineEditandDateTimeEdit: a failingonSaveis caught, and the editor stays open with the user's value instead of throwing an unhandled rejection.SearchTable:isLoading,isErrorandonRetryprops, with an error row and Retry.SearchTable.Components moved to TanStack Query, with an error and Retry instead of an endless skeleton:
["projects", id, "sender-identities", …].["projects", id, "providers", "list"], also used by the settings PR), so whichever page loads first can't cap the cached list at 20.["projects", "list"]and["organizations", "list"], so other pages can refresh them after a rename.Cleanup:
provider/select.tsxdeleted (unused).components/inbox/,components/scheduled/andcomponents/sender-identity/.Testing
New tests, each failing against the old code unless marked:
hooks.test.tssearch-table.test.tsxscheduled-detail-table.test.tsxui/inline-edit.test.tsxsender-identity/sender-identity.test.tsxmedia-manager/MediaManager.test.tsxinbox-detail-table.test.tsxui/user-import-dialog.test.tsxaction-preview-iframe.test.tsxAll 113 console tests pass.
vite buildsucceeds, with no new type errors.Manual check:
Notes
search-table.tsx(426 lines) andscheduled-detail-table.tsx(453) are slightly over the 400-line target.Depends-On: #329