mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 16:59:12 +00:00
feat(web): move from react-router to @tanstack/router (#1338)
* fix(auth): invalid cookie handling and wrongful basic auth invalidation * fix(auth): fix test to reflect new HTTP status code * fix(auth/web): do not throw on error * fix(http): replace http codes in middleware to prevent basic auth invalidation fix typo in comment * fix test * fix(web): api client handle 403 * refactor(http): auth_test use testify.assert * refactor(http): set session opts after valid login * refactor(http): send more client headers * fix(http): test * refactor(web): move router to tanstack/router * refactor(web): use route loaders and suspense * refactor(web): useSuspense for settings * refactor(web): invalidate cookie in middleware * fix: loclfile * fix: load filter/id * fix(web): login, onboard, types, imports * fix(web): filter load * fix(web): build errors * fix(web): ts-expect-error * fix(tests): filter_test.go * fix(filters): tests * refactor: remove duplicate spinner components refactor: ReleaseTable.tsx loading animation refactor: remove dedicated `pendingComponent` for `settingsRoute` * fix: refactor missed SectionLoader to RingResizeSpinner * fix: substitute divides with borders to account for unloaded elements * fix(api): action status URL param * revert: action status URL param add comment * fix(routing): notfound handling and split files * fix(filters): notfound get params * fix(queries): colon * fix(queries): comments ts-ignore * fix(queries): extract queryKeys * fix(queries): remove err * fix(routes): move zob schema inline * fix(auth): middleware and redirect to login * fix(auth): failing test * fix(logs): invalidate correct key * fix(logs): invalidate correct key * fix(logs): invalidate correct key * fix: JSX element stealing focus from searchbar * reimplement empty release table state text * fix(context): use deep-copy * fix(releases): empty state and filter input warnings * fix(releases): empty states * fix(auth): onboarding * fix(cache): invalidate queries --------- Co-authored-by: ze0s <43699394+zze0s@users.noreply.github.com>
This commit is contained in:
parent
cc9656cd41
commit
1a23b69bcf
64 changed files with 2543 additions and 2091 deletions
|
@ -3,60 +3,34 @@
|
|||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
import { QueryClient, QueryClientProvider, useQueryErrorResetBoundary } from "@tanstack/react-query";
|
||||
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
||||
import { ErrorBoundary } from "react-error-boundary";
|
||||
import { toast, Toaster } from "react-hot-toast";
|
||||
|
||||
import { LocalRouter } from "./domain/routes";
|
||||
import { AuthContext, SettingsContext } from "./utils/Context";
|
||||
import { ErrorPage } from "./components/alerts";
|
||||
import Toast from "./components/notifications/Toast";
|
||||
import { RouterProvider } from "@tanstack/react-router"
|
||||
import { QueryClientProvider } from "@tanstack/react-query";
|
||||
import { Toaster } from "react-hot-toast";
|
||||
import { Portal } from "react-portal";
|
||||
import { Router } from "@app/routes";
|
||||
import { routerBasePath } from "@utils";
|
||||
import { queryClient } from "@api/QueryClient";
|
||||
import { AuthContext } from "@utils/Context";
|
||||
|
||||
const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
// The retries will have exponential delay.
|
||||
// See https://tanstack.com/query/v4/docs/guides/query-retries#retry-delay
|
||||
// delay = Math.min(1000 * 2 ** attemptIndex, 30000)
|
||||
retry: true,
|
||||
throwOnError: true,
|
||||
},
|
||||
mutations: {
|
||||
onError: (error) => {
|
||||
// Use a format string to convert the error object to a proper string without much hassle.
|
||||
const message = (
|
||||
typeof (error) === "object" && typeof ((error as Error).message) ?
|
||||
(error as Error).message :
|
||||
`${error}`
|
||||
);
|
||||
toast.custom((t) => <Toast type="error" body={message} t={t} />);
|
||||
}
|
||||
}
|
||||
declare module '@tanstack/react-router' {
|
||||
interface Register {
|
||||
router: typeof Router
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function App() {
|
||||
const { reset } = useQueryErrorResetBoundary();
|
||||
|
||||
const authContext = AuthContext.useValue();
|
||||
const settings = SettingsContext.useValue();
|
||||
|
||||
return (
|
||||
<ErrorBoundary
|
||||
onReset={reset}
|
||||
FallbackComponent={ErrorPage}
|
||||
>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<Portal>
|
||||
<Toaster position="top-right" />
|
||||
</Portal>
|
||||
<LocalRouter isLoggedIn={authContext.isLoggedIn} />
|
||||
{settings.debug ? (
|
||||
<ReactQueryDevtools initialIsOpen={false} />
|
||||
) : null}
|
||||
<RouterProvider
|
||||
basepath={routerBasePath()}
|
||||
router={Router}
|
||||
context={{
|
||||
auth: AuthContext,
|
||||
}}
|
||||
/>
|
||||
</QueryClientProvider>
|
||||
</ErrorBoundary>
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue