Skip to content

Commit

Permalink
refactor(web): drop useDataInvalidator
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Jul 10, 2024
1 parent 666bc9c commit bac70f6
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 123 deletions.
3 changes: 0 additions & 3 deletions web/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ import { useInstallerClientStatus } from "~/context/installer";
import { useProduct } from "./context/product";
import { CONFIG, INSTALL, STARTUP } from "~/client/phase";
import { BUSY } from "~/client/status";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { useL10nConfigChanges } from "~/queries/l10n";

const queryClient = new QueryClient();

/**
* Main application component.
*
Expand Down
2 changes: 1 addition & 1 deletion web/src/context/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ function AppProviders({ children }) {
);
}

export { AppProviders, queryClient };
export { AppProviders };
65 changes: 0 additions & 65 deletions web/src/queries/hooks.js

This file was deleted.

49 changes: 0 additions & 49 deletions web/src/queries/hooks.test.js

This file was deleted.

9 changes: 4 additions & 5 deletions web/src/queries/l10n.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
*/

import React from "react";
import { useQueryClient, useMutation, useSuspenseQuery, useSuspenseQueries } from "@tanstack/react-query";
import { useQueryClient, useMutation, useSuspenseQueries } from "@tanstack/react-query";
import { useInstallerClient } from "~/context/installer";
import { useDataInvalidator } from "~/queries/hooks";
import { timezoneUTCOffset } from "~/utils";

/**
Expand Down Expand Up @@ -108,18 +107,18 @@ const useConfigMutation = () => {
* revalidate its data (executing the loaders again).
*/
const useL10nConfigChanges = () => {
const dataInvalidator = useDataInvalidator();
const queryClient = useQueryClient();
const client = useInstallerClient();

React.useEffect(() => {
if (!client) return;

return client.ws().onEvent(event => {
if (event.type === "L10nConfigChanged") {
dataInvalidator({ queryKey: ["l10n", "config"] });
queryClient.invalidateQueries({ queryKey });
}
});
}, [client, dataInvalidator]);
}, [client, queryClient]);
};

/// Returns the l10n data.
Expand Down

0 comments on commit bac70f6

Please sign in to comment.