Skip to content

Commit

Permalink
inertia - upgraded deps
Browse files Browse the repository at this point in the history
  • Loading branch information
dcordz committed Oct 23, 2024
1 parent 9c8490e commit 42d185d
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 159 deletions.
9 changes: 0 additions & 9 deletions app/frontend/hooks/useLegislatorVotes.ts

This file was deleted.

9 changes: 1 addition & 8 deletions app/frontend/hooks/useLocales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@
import { router, usePage } from "@inertiajs/react";
import { useCallback, useMemo } from "react";
import { ISelectOption, sway } from "sway";
import { SWAY_STORAGE, logDev, sessionGet, toFormattedLocaleName } from "../sway_utils";

export const getDefaultSwayLocale = () => {
const sessionLocale = sessionGet(SWAY_STORAGE.Session.User.Locale);
if (sessionLocale) {
return JSON.parse(sessionLocale);
}
};
import { logDev, toFormattedLocaleName } from "../sway_utils";

const toSelectOption = (l: sway.ISwayLocale): ISelectOption => ({ label: toFormattedLocaleName(l.name), value: l.id });

Expand Down
67 changes: 0 additions & 67 deletions app/frontend/hooks/useRepresentatives.ts

This file was deleted.

49 changes: 0 additions & 49 deletions app/frontend/hooks/useThrottle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,6 @@ import { useCallback, useRef } from "react";

const DEFAULT_THROTTLE_DELAY_MS = 50;

type TThrottler = (func: (...args: any[]) => any, delay?: number) => any;

/**
* Return a memoized throttle function
*
* @returns
*/
export const useThrottle = (): TThrottler => {
const throttleRef = useRef<boolean>(false);
return useCallback((func, delay = DEFAULT_THROTTLE_DELAY_MS) => {
if (throttleRef.current) {
return;
}
throttleRef.current = true;
func();
setTimeout(() => {
throttleRef.current = false;
}, delay);
}, []);
};

/**
* Return a memoized throttle function
*
* @returns
*/
type TFunc = (...args: any[]) => unknown;
export const useThrottleFunction = (
func: TFunc | undefined,
delay = DEFAULT_THROTTLE_DELAY_MS,
defaultResponseValue: any = undefined,
): ((...args: any[]) => unknown) => {
const throttleRef = useRef<boolean>(false);
return useCallback(
(...args: any[]) => {
if (!func) return;

if (throttleRef.current) {
return defaultResponseValue;
}
throttleRef.current = true;
func(...args);
setTimeout(() => {
throttleRef.current = false;
}, delay);
},
[func, delay, defaultResponseValue],
);
};
/**
* Return a memoized throttle function
*
Expand Down
4 changes: 2 additions & 2 deletions app/frontend/pages/Bill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ interface IProps {
userVote?: sway.IUserVote;
}

const _Bill: React.FC<IProps> = (props) => {
const Bill_: React.FC<IProps> = (props) => {
return <BillComponent {...props} />;
};

const Bill = _Bill;
const Bill = Bill_;
export default Bill;
4 changes: 2 additions & 2 deletions app/frontend/pages/Bills.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import BillsListCategoriesHeader from "../components/bill/BillsListCategoriesHea
import BillsListItem from "../components/bill/BillsListItem";
import LocaleSelector from "../components/user/LocaleSelector";

const _Bills: React.FC<{ bills: sway.IBill[] }> = ({ bills }) => {
const Bills_: React.FC<{ bills: sway.IBill[] }> = ({ bills }) => {
const [locale] = useLocale();
const [categories, setCategories] = useState<string[]>([]);

Expand Down Expand Up @@ -53,5 +53,5 @@ const _Bills: React.FC<{ bills: sway.IBill[] }> = ({ bills }) => {
);
};

const Bills = _Bills;
const Bills = Bills_;
export default Bills;
3 changes: 1 addition & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import rulesOfHooks from "eslint-plugin-react-hooks";
import eslintImport from "eslint-plugin-import";
import typescriptParser from "@typescript-eslint/parser";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import { fixupPluginRules } from "@eslint/compat";

export default [
// pluginJs.configs.recommended,
Expand All @@ -32,7 +31,7 @@ export default [
plugins: {
"@typescript-eslint": typescriptEslint,
"react-refresh": reactRefresh,
"react-hooks": fixupPluginRules(rulesOfHooks),
"react-hooks": rulesOfHooks,
import: eslintImport,
},
},
Expand Down
19 changes: 0 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"yup": "^1.4.0"
},
"devDependencies": {
"@eslint/compat": "^1.2.1",
"@eslint/js": "^9.13.0",
"@types/eslint__js": "^8.42.3",
"@types/lodash": "^4.17.12",
Expand Down

0 comments on commit 42d185d

Please sign in to comment.