feat(web): Add a global query fetch/mutation status

This commit is contained in:
Prayag Prajapati committed 2024-02-19 19:22:41 +05:30
1 parent 778c8f8039
commit 9d28aaae96
6 files changed
+185 -22

No files matched your search

+15 -13
View File
@@ -108,6 +108,12 @@ import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import { useSnackbar } from "notistack";
import { ErrorBoundary } from "react-error-boundary";
import {
useIsFetching,
useIsMutating,
useQueryClient,
} from "@tanstack/react-query";
import NProgress from "./components/nProgress";
import Settings from "./components/settings";
import { EasterEgg } from "./components/utils/easterEgg.jsx";
import { handleRelaunch } from "./utils/misc/relaunch";
@@ -241,6 +247,11 @@ function AppReady() {
undefined,
);
const isQueryFetching = useIsFetching();
const isMutating = useIsMutating();
console.info(location.pathname + "----" + isQueryFetching);
useLayoutEffect(() => {
async function checkForUpdates() {
try {
@@ -278,19 +289,10 @@ function AppReady() {
<SnackbarProvider maxSnack={5}>
<ThemeProvider theme={theme}>
<CssBaseline />
{playbackDataLoading && (
<LinearProgress
sx={{
position: "fixed",
top: 0,
left: 0,
right: 0,
width: "100vw",
zIndex: 100000,
}}
/>
)}
<NProgress
isAnimating={isQueryFetching}
key={isQueryFetching || isMutating ? "fetching" : "notFetching"}
/>
<Dialog
open={updateDialog}
fullWidth
+36
View File
@@ -0,0 +1,36 @@
import { LinearProgress } from "@mui/material";
import { useNProgress } from "@tanem/react-nprogress";
import React from "react";
const NProgress: React.FC<{ isAnimating: boolean | number }> = ({
isAnimating,
}) => {
const { animationDuration, isFinished, progress } = useNProgress({
isAnimating,
});
return (
<div
style={{
opacity: isFinished ? 0 : 1,
pointerEvents: "none",
transition: `opacity ${animationDuration}ms linear`,
position: "fixed",
top: "0",
left: "0",
right: "0",
zIndex: "10000",
}}
>
<LinearProgress
sx={{
transitionDuration: animationDuration,
}}
value={progress * 100}
variant="determinate"
/>
</div>
);
};
export default NProgress;
-8
View File
@@ -10,14 +10,6 @@ const ItemSkeleton = () => {
width: "100vw",
}}
>
<LinearProgress
sx={{
position: "fixed",
top: "0",
left: 0,
right: 0,
}}
/>
<div
className="item-hero flex flex-row"
style={{