diff options
author | Anderson Shindy Oki <[email protected]> | 2024-08-29 16:49:13 +0900 |
---|---|---|
committer | GitHub <[email protected]> | 2024-08-29 16:49:13 +0900 |
commit | fb3722f1382aed14c6085b799db578413ca45777 (patch) | |
tree | 8923f12a6a478414024b5dd278c81a74a96fe82a /frontend/src | |
parent | 02a91253f0a1eeda85416ccf4da9e7e2f46194ac (diff) | |
download | bazarr-fb3722f1382aed14c6085b799db578413ca45777.tar.gz bazarr-fb3722f1382aed14c6085b799db578413ca45777.zip |
no log: Eslint plugin updates (#2574)
Diffstat (limited to 'frontend/src')
-rw-r--r-- | frontend/src/apis/hooks/episodes.ts | 26 | ||||
-rw-r--r-- | frontend/src/apis/hooks/movies.ts | 33 | ||||
-rw-r--r-- | frontend/src/apis/hooks/system.ts | 37 | ||||
-rw-r--r-- | frontend/src/components/async/MutateAction.tsx | 1 | ||||
-rw-r--r-- | frontend/src/components/async/MutateButton.tsx | 1 | ||||
-rw-r--r-- | frontend/src/components/async/QueryOverlay.tsx | 2 | ||||
-rw-r--r-- | frontend/src/components/inputs/Selector.tsx | 5 | ||||
-rw-r--r-- | frontend/src/modules/modals/hooks.ts | 13 | ||||
-rw-r--r-- | frontend/src/modules/socketio/reducer.ts | 52 | ||||
-rw-r--r-- | frontend/src/pages/Settings/components/forms.test.tsx | 8 | ||||
-rw-r--r-- | frontend/src/pages/Settings/components/forms.tsx | 10 |
11 files changed, 79 insertions, 109 deletions
diff --git a/frontend/src/apis/hooks/episodes.ts b/frontend/src/apis/hooks/episodes.ts index 6a489e938..956fd103f 100644 --- a/frontend/src/apis/hooks/episodes.ts +++ b/frontend/src/apis/hooks/episodes.ts @@ -25,23 +25,6 @@ const cacheEpisodes = (client: QueryClient, episodes: Item.Episode[]) => { }); }; -export function useEpisodesByIds(ids: number[]) { - const client = useQueryClient(); - - const query = useQuery({ - queryKey: [QueryKeys.Series, QueryKeys.Episodes, ids], - queryFn: () => api.episodes.byEpisodeId(ids), - }); - - useEffect(() => { - if (query.isSuccess && query.data) { - cacheEpisodes(client, query.data); - } - }, [query.isSuccess, query.data, client]); - - return query; -} - export function useEpisodesBySeriesId(id: number) { const client = useQueryClient(); @@ -87,10 +70,11 @@ export function useEpisodeAddBlacklist() { }, onSuccess: (_, { seriesId }) => { - client.invalidateQueries({ + void client.invalidateQueries({ queryKey: [QueryKeys.Series, QueryKeys.Episodes, QueryKeys.Blacklist], }); - client.invalidateQueries({ + + void client.invalidateQueries({ queryKey: [QueryKeys.Series, seriesId], }); }, @@ -105,8 +89,8 @@ export function useEpisodeDeleteBlacklist() { mutationFn: (param: { all?: boolean; form?: FormType.DeleteBlacklist }) => api.episodes.deleteBlacklist(param.all, param.form), - onSuccess: (_) => { - client.invalidateQueries({ + onSuccess: () => { + void client.invalidateQueries({ queryKey: [QueryKeys.Series, QueryKeys.Episodes, QueryKeys.Blacklist], }); }, diff --git a/frontend/src/apis/hooks/movies.ts b/frontend/src/apis/hooks/movies.ts index cf4594cbe..6b1c5c2a5 100644 --- a/frontend/src/apis/hooks/movies.ts +++ b/frontend/src/apis/hooks/movies.ts @@ -15,23 +15,6 @@ const cacheMovies = (client: QueryClient, movies: Item.Movie[]) => { }); }; -export function useMoviesByIds(ids: number[]) { - const client = useQueryClient(); - - const query = useQuery({ - queryKey: [QueryKeys.Movies, ...ids], - queryFn: () => api.movies.movies(ids), - }); - - useEffect(() => { - if (query.isSuccess && query.data) { - cacheMovies(client, query.data); - } - }, [query.isSuccess, query.data, client]); - - return query; -} - export function useMovieById(id: number) { return useQuery({ queryKey: [QueryKeys.Movies, id], @@ -74,12 +57,13 @@ export function useMovieModification() { onSuccess: (_, form) => { form.id.forEach((v) => { - client.invalidateQueries({ + void client.invalidateQueries({ queryKey: [QueryKeys.Movies, v], }); }); + // TODO: query less - client.invalidateQueries({ + void client.invalidateQueries({ queryKey: [QueryKeys.Movies], }); }, @@ -93,7 +77,7 @@ export function useMovieAction() { mutationFn: (form: FormType.MoviesAction) => api.movies.action(form), onSuccess: () => { - client.invalidateQueries({ + void client.invalidateQueries({ queryKey: [QueryKeys.Movies], }); }, @@ -125,10 +109,11 @@ export function useMovieAddBlacklist() { }, onSuccess: (_, { id }) => { - client.invalidateQueries({ + void client.invalidateQueries({ queryKey: [QueryKeys.Movies, QueryKeys.Blacklist], }); - client.invalidateQueries({ + + void client.invalidateQueries({ queryKey: [QueryKeys.Movies, id], }); }, @@ -143,8 +128,8 @@ export function useMovieDeleteBlacklist() { mutationFn: (param: { all?: boolean; form?: FormType.DeleteBlacklist }) => api.movies.deleteBlacklist(param.all, param.form), - onSuccess: (_, param) => { - client.invalidateQueries({ + onSuccess: () => { + void client.invalidateQueries({ queryKey: [QueryKeys.Movies, QueryKeys.Blacklist], }); }, diff --git a/frontend/src/apis/hooks/system.ts b/frontend/src/apis/hooks/system.ts index 109e77105..a0ce17fb9 100644 --- a/frontend/src/apis/hooks/system.ts +++ b/frontend/src/apis/hooks/system.ts @@ -54,22 +54,27 @@ export function useSettingsMutation() { mutationFn: (data: LooseObject) => api.system.updateSettings(data), onSuccess: () => { - client.invalidateQueries({ + void client.invalidateQueries({ queryKey: [QueryKeys.System], }); - client.invalidateQueries({ + + void client.invalidateQueries({ queryKey: [QueryKeys.Series], }); - client.invalidateQueries({ + + void client.invalidateQueries({ queryKey: [QueryKeys.Episodes], }); - client.invalidateQueries({ + + void client.invalidateQueries({ queryKey: [QueryKeys.Movies], }); - client.invalidateQueries({ + + void client.invalidateQueries({ queryKey: [QueryKeys.Wanted], }); - client.invalidateQueries({ + + void client.invalidateQueries({ queryKey: [QueryKeys.Badges], }); }, @@ -101,7 +106,7 @@ export function useDeleteLogs() { mutationFn: () => api.system.deleteLogs(), onSuccess: () => { - client.invalidateQueries({ + void client.invalidateQueries({ queryKey: [QueryKeys.System, QueryKeys.Logs], }); }, @@ -128,11 +133,12 @@ export function useSystemAnnouncementsAddDismiss() { return api.system.addAnnouncementsDismiss(hash); }, - onSuccess: (_, { hash }) => { - client.invalidateQueries({ + onSuccess: () => { + void client.invalidateQueries({ queryKey: [QueryKeys.System, QueryKeys.Announcements], }); - client.invalidateQueries({ + + void client.invalidateQueries({ queryKey: [QueryKeys.System, QueryKeys.Badges], }); }, @@ -156,10 +162,11 @@ export function useRunTask() { mutationFn: (id: string) => api.system.runTask(id), onSuccess: () => { - client.invalidateQueries({ + void client.invalidateQueries({ queryKey: [QueryKeys.System, QueryKeys.Tasks], }); - client.invalidateQueries({ + + void client.invalidateQueries({ queryKey: [QueryKeys.System, QueryKeys.Backups], }); }, @@ -180,7 +187,7 @@ export function useCreateBackups() { mutationFn: () => api.system.createBackups(), onSuccess: () => { - client.invalidateQueries({ + void client.invalidateQueries({ queryKey: [QueryKeys.System, QueryKeys.Backups], }); }, @@ -194,7 +201,7 @@ export function useRestoreBackups() { mutationFn: (filename: string) => api.system.restoreBackups(filename), onSuccess: () => { - client.invalidateQueries({ + void client.invalidateQueries({ queryKey: [QueryKeys.System, QueryKeys.Backups], }); }, @@ -208,7 +215,7 @@ export function useDeleteBackups() { mutationFn: (filename: string) => api.system.deleteBackups(filename), onSuccess: () => { - client.invalidateQueries({ + void client.invalidateQueries({ queryKey: [QueryKeys.System, QueryKeys.Backups], }); }, diff --git a/frontend/src/components/async/MutateAction.tsx b/frontend/src/components/async/MutateAction.tsx index 6fff0dbb7..92c102ea9 100644 --- a/frontend/src/components/async/MutateAction.tsx +++ b/frontend/src/components/async/MutateAction.tsx @@ -16,7 +16,6 @@ type MutateActionProps<DATA, VAR> = Omit< function MutateAction<DATA, VAR>({ mutation, - noReset, onSuccess, onError, args, diff --git a/frontend/src/components/async/MutateButton.tsx b/frontend/src/components/async/MutateButton.tsx index 9197e2d50..908c2dfda 100644 --- a/frontend/src/components/async/MutateButton.tsx +++ b/frontend/src/components/async/MutateButton.tsx @@ -15,7 +15,6 @@ type MutateButtonProps<DATA, VAR> = Omit< function MutateButton<DATA, VAR>({ mutation, - noReset, onSuccess, onError, args, diff --git a/frontend/src/components/async/QueryOverlay.tsx b/frontend/src/components/async/QueryOverlay.tsx index 2a5848cf2..1672989ff 100644 --- a/frontend/src/components/async/QueryOverlay.tsx +++ b/frontend/src/components/async/QueryOverlay.tsx @@ -12,7 +12,7 @@ interface QueryOverlayProps { const QueryOverlay: FunctionComponent<QueryOverlayProps> = ({ children, global = false, - result: { isLoading, isError, error }, + result: { isLoading }, }) => { return ( <LoadingProvider value={isLoading}> diff --git a/frontend/src/components/inputs/Selector.tsx b/frontend/src/components/inputs/Selector.tsx index 1825d314a..092fd24e7 100644 --- a/frontend/src/components/inputs/Selector.tsx +++ b/frontend/src/components/inputs/Selector.tsx @@ -7,7 +7,7 @@ import { Select, SelectProps, } from "@mantine/core"; -import { isNull, isUndefined, noop } from "lodash"; +import { isNull, isUndefined } from "lodash"; import { LOG } from "@/utilities/console"; export type SelectorOption<T> = Override< @@ -49,10 +49,7 @@ export type GroupedSelectorProps<T> = Override< >; export function GroupedSelector<T>({ - value, options, - getkey = DefaultKeyBuilder, - onOptionSubmit = noop, ...select }: GroupedSelectorProps<T>) { return ( diff --git a/frontend/src/modules/modals/hooks.ts b/frontend/src/modules/modals/hooks.ts index 09855ac51..667e429d3 100644 --- a/frontend/src/modules/modals/hooks.ts +++ b/frontend/src/modules/modals/hooks.ts @@ -5,11 +5,8 @@ import { ModalSettings } from "@mantine/modals/lib/context"; import { ModalComponent, ModalIdContext } from "./WithModal"; export function useModals() { - const { - openContextModal: openMantineContextModal, - closeContextModal: closeContextModalRaw, - ...rest - } = useMantineModals(); + const { openContextModal: openMantineContextModal, ...rest } = + useMantineModals(); const openContextModal = useCallback( <ARGS extends {}>( @@ -26,7 +23,7 @@ export function useModals() { [openMantineContextModal], ); - const closeContextModal = useCallback( + const closeContext = useCallback( (modal: ModalComponent) => { rest.closeModal(modal.modalKey); }, @@ -43,7 +40,7 @@ export function useModals() { // TODO: Performance return useMemo( - () => ({ openContextModal, closeContextModal, closeSelf, ...rest }), - [closeContextModal, closeSelf, openContextModal, rest], + () => ({ openContextModal, closeContext, closeSelf, ...rest }), + [closeContext, closeSelf, openContextModal, rest], ); } diff --git a/frontend/src/modules/socketio/reducer.ts b/frontend/src/modules/socketio/reducer.ts index d19ff87c4..378ab12fc 100644 --- a/frontend/src/modules/socketio/reducer.ts +++ b/frontend/src/modules/socketio/reducer.ts @@ -40,13 +40,17 @@ export function createDefaultReducer(): SocketIO.Reducer[] { update: (ids) => { LOG("info", "Invalidating series", ids); ids.forEach((id) => { - queryClient.invalidateQueries({ queryKey: [QueryKeys.Series, id] }); + void queryClient.invalidateQueries({ + queryKey: [QueryKeys.Series, id], + }); }); }, delete: (ids) => { LOG("info", "Invalidating series", ids); ids.forEach((id) => { - queryClient.invalidateQueries({ queryKey: [QueryKeys.Series, id] }); + void queryClient.invalidateQueries({ + queryKey: [QueryKeys.Series, id], + }); }); }, }, @@ -55,13 +59,17 @@ export function createDefaultReducer(): SocketIO.Reducer[] { update: (ids) => { LOG("info", "Invalidating movies", ids); ids.forEach((id) => { - queryClient.invalidateQueries({ queryKey: [QueryKeys.Movies, id] }); + void queryClient.invalidateQueries({ + queryKey: [QueryKeys.Movies, id], + }); }); }, delete: (ids) => { LOG("info", "Invalidating movies", ids); ids.forEach((id) => { - queryClient.invalidateQueries({ queryKey: [QueryKeys.Movies, id] }); + void queryClient.invalidateQueries({ + queryKey: [QueryKeys.Movies, id], + }); }); }, }, @@ -78,7 +86,7 @@ export function createDefaultReducer(): SocketIO.Reducer[] { id, ]); if (episode !== undefined) { - queryClient.invalidateQueries({ + void queryClient.invalidateQueries({ queryKey: [QueryKeys.Series, episode.sonarrSeriesId], }); } @@ -92,7 +100,7 @@ export function createDefaultReducer(): SocketIO.Reducer[] { id, ]); if (episode !== undefined) { - queryClient.invalidateQueries({ + void queryClient.invalidateQueries({ queryKey: [QueryKeys.Series, episode.sonarrSeriesId], }); } @@ -101,28 +109,28 @@ export function createDefaultReducer(): SocketIO.Reducer[] { }, { key: "episode-wanted", - update: (ids) => { + update: () => { // Find a better way to update wanted - queryClient.invalidateQueries({ + void queryClient.invalidateQueries({ queryKey: [QueryKeys.Episodes, QueryKeys.Wanted], }); }, delete: () => { - queryClient.invalidateQueries({ + void queryClient.invalidateQueries({ queryKey: [QueryKeys.Episodes, QueryKeys.Wanted], }); }, }, { key: "movie-wanted", - update: (ids) => { + update: () => { // Find a better way to update wanted - queryClient.invalidateQueries({ + void queryClient.invalidateQueries({ queryKey: [QueryKeys.Movies, QueryKeys.Wanted], }); }, delete: () => { - queryClient.invalidateQueries({ + void queryClient.invalidateQueries({ queryKey: [QueryKeys.Movies, QueryKeys.Wanted], }); }, @@ -130,13 +138,13 @@ export function createDefaultReducer(): SocketIO.Reducer[] { { key: "settings", any: () => { - queryClient.invalidateQueries({ queryKey: [QueryKeys.System] }); + void queryClient.invalidateQueries({ queryKey: [QueryKeys.System] }); }, }, { key: "languages", any: () => { - queryClient.invalidateQueries({ + void queryClient.invalidateQueries({ queryKey: [QueryKeys.System, QueryKeys.Languages], }); }, @@ -144,7 +152,7 @@ export function createDefaultReducer(): SocketIO.Reducer[] { { key: "badges", any: () => { - queryClient.invalidateQueries({ + void queryClient.invalidateQueries({ queryKey: [QueryKeys.System, QueryKeys.Badges], }); }, @@ -152,7 +160,7 @@ export function createDefaultReducer(): SocketIO.Reducer[] { { key: "movie-history", any: () => { - queryClient.invalidateQueries({ + void queryClient.invalidateQueries({ queryKey: [QueryKeys.Movies, QueryKeys.History], }); }, @@ -160,7 +168,7 @@ export function createDefaultReducer(): SocketIO.Reducer[] { { key: "movie-blacklist", any: () => { - queryClient.invalidateQueries({ + void queryClient.invalidateQueries({ queryKey: [QueryKeys.Movies, QueryKeys.Blacklist], }); }, @@ -168,7 +176,7 @@ export function createDefaultReducer(): SocketIO.Reducer[] { { key: "episode-history", any: () => { - queryClient.invalidateQueries({ + void queryClient.invalidateQueries({ queryKey: [QueryKeys.Episodes, QueryKeys.History], }); }, @@ -176,7 +184,7 @@ export function createDefaultReducer(): SocketIO.Reducer[] { { key: "episode-blacklist", any: () => { - queryClient.invalidateQueries({ + void queryClient.invalidateQueries({ queryKey: [QueryKeys.Episodes, QueryKeys.Blacklist], }); }, @@ -184,7 +192,7 @@ export function createDefaultReducer(): SocketIO.Reducer[] { { key: "reset-episode-wanted", any: () => { - queryClient.invalidateQueries({ + void queryClient.invalidateQueries({ queryKey: [QueryKeys.Episodes, QueryKeys.Wanted], }); }, @@ -192,7 +200,7 @@ export function createDefaultReducer(): SocketIO.Reducer[] { { key: "reset-movie-wanted", any: () => { - queryClient.invalidateQueries({ + void queryClient.invalidateQueries({ queryKey: [QueryKeys.Movies, QueryKeys.Wanted], }); }, @@ -200,7 +208,7 @@ export function createDefaultReducer(): SocketIO.Reducer[] { { key: "task", any: () => { - queryClient.invalidateQueries({ + void queryClient.invalidateQueries({ queryKey: [QueryKeys.System, QueryKeys.Tasks], }); }, diff --git a/frontend/src/pages/Settings/components/forms.test.tsx b/frontend/src/pages/Settings/components/forms.test.tsx index a88d2bec7..4ec60699b 100644 --- a/frontend/src/pages/Settings/components/forms.test.tsx +++ b/frontend/src/pages/Settings/components/forms.test.tsx @@ -2,7 +2,7 @@ import { FunctionComponent, PropsWithChildren, ReactElement } from "react"; import { useForm } from "@mantine/form"; import { describe, it } from "vitest"; import { FormContext, FormValues } from "@/pages/Settings/utilities/FormValues"; -import { render, RenderOptions, screen } from "@/tests"; +import { render, screen } from "@/tests"; import { Number, Text } from "./forms"; const FormSupport: FunctionComponent<PropsWithChildren> = ({ children }) => { @@ -15,10 +15,8 @@ const FormSupport: FunctionComponent<PropsWithChildren> = ({ children }) => { return <FormContext.Provider value={form}>{children}</FormContext.Provider>; }; -const formRender = ( - ui: ReactElement, - options?: Omit<RenderOptions, "wrapper">, -) => render(<FormSupport>{ui}</FormSupport>); +const formRender = (ui: ReactElement) => + render(<FormSupport>{ui}</FormSupport>); describe("Settings form", () => { describe("number component", () => { diff --git a/frontend/src/pages/Settings/components/forms.tsx b/frontend/src/pages/Settings/components/forms.tsx index 1e4f744b9..43b559736 100644 --- a/frontend/src/pages/Settings/components/forms.tsx +++ b/frontend/src/pages/Settings/components/forms.tsx @@ -1,4 +1,4 @@ -import { FunctionComponent, ReactNode, ReactText } from "react"; +import { FunctionComponent, ReactNode } from "react"; import { Input, NumberInput, @@ -49,7 +49,7 @@ export const Number: FunctionComponent<NumberProps> = (props) => { ); }; -export type TextProps = BaseInput<ReactText> & TextInputProps; +export type TextProps = BaseInput<string | number> & TextInputProps; export const Text: FunctionComponent<TextProps> = (props) => { const { value, update, rest } = useBaseInput(props); @@ -86,11 +86,7 @@ export interface CheckProps extends BaseInput<boolean> { inline?: boolean; } -export const Check: FunctionComponent<CheckProps> = ({ - label, - inline, - ...props -}) => { +export const Check: FunctionComponent<CheckProps> = ({ label, ...props }) => { const { value, update, rest } = useBaseInput(props); return ( |