Skip to content

Commit

Permalink
enhancement: second commit moving loader functions to their own file.
Browse files Browse the repository at this point in the history
  • Loading branch information
alifeinbinary committed Oct 8, 2024
1 parent 931ebe5 commit 8a43043
Show file tree
Hide file tree
Showing 16 changed files with 302 additions and 766 deletions.
7 changes: 2 additions & 5 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import tseslint from "typescript-eslint";
export default tseslint.config(
{ ignores: ["dist"] },
{
extends: [
js.configs.recommended,
...tseslint.configs.recommended,
"plugin:prettier/recommended",
],
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ["**/*.{ts,tsx}"],
languageOptions: {
ecmaVersion: 2020,
Expand All @@ -27,6 +23,7 @@ export default tseslint.config(
"warn",
{ allowConstantExport: true },
],
"@typescript-eslint/no-explicit-any": "off",
},
},
);
956 changes: 264 additions & 692 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"fabricjs-react": "^2.0.0",
"file-saver": "^2.0.5",
"flowbite-react": "^0.10.2",
"framer-motion": "^11.11.1",
"framer-motion": "^11.11.3",
"i18next": "^23.15.2",
"i18next-browser-languagedetector": "^8.0.0",
"i18next-http-backend": "^2.6.2",
Expand All @@ -45,18 +45,19 @@
"@testing-library/react": "^16.0.1",
"@types/crypto-js": "^4.2.2",
"@types/file-saver": "^2.0.7",
"@types/mocha": "^10.0.8",
"@types/node": "^22.7.4",
"@types/mocha": "^10.0.9",
"@types/node": "^22.7.5",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.0",
"@types/react-router-dom": "^5.3.3",
"@types/testing-library__jest-dom": "^5.14.9",
"@types/yargs": "^17.0.33",
"@typescript-eslint/parser": "^8.8.0",
"@typescript-eslint/eslint-plugin": "^8.8.1",
"@typescript-eslint/parser": "^8.8.1",
"@vitejs/plugin-react": "^4.3.2",
"autoprefixer": "^10.4.20",
"babel-jest": "^29.7.0",
"eslint": "^9.12.0",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.37.1",
Expand All @@ -75,9 +76,10 @@
"rollup-plugin-visualizer": "^5.12.0",
"tailwindcss": "^3.4.13",
"typescript": "^5.6.2",
"typescript-eslint": "^8.8.0",
"typescript-eslint": "^8.8.1",
"vite": "^5.4.8",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-eslint": "^1.8.1",
"vite-plugin-minify": "^2.0.0",
"vite-plugin-sitemap": "^0.7.1",
"vite-plugin-tailwind-purgecss": "^0.3.3"
Expand Down
6 changes: 3 additions & 3 deletions src/components/DebugConsole.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ const DebugConsole = () => {

// Keeping it fresh in the console
useEffect(() => {
if (!DEBUG) {
console.clear();
}
// if (!DEBUG) {
// console.clear();
// }

// Debug console
const items = {
Expand Down
1 change: 1 addition & 0 deletions src/components/Feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const Feed: FC = (): ReactElement => {
};

fetchInitialPosts();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

if (loading) return (
Expand Down
4 changes: 2 additions & 2 deletions src/components/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const Menu: React.FC = () => {
path.style.transition = 'fill 1s ease-in-out';
path.style.fill = randomColour;
}
letters?.forEach((letter, _index) => {
letters?.forEach((letter) => {
let randomLetterColourIndex = Math.floor(Math.random() * colourList.length);
while (randomLetterColourIndex === randomColourIndex) {
randomLetterColourIndex = Math.floor(Math.random() * colourList.length);
Expand Down Expand Up @@ -125,7 +125,7 @@ const Menu: React.FC = () => {
}
};
}
}, [theme]);
}, [colourList, theme]);

return (
<div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const Post: React.FC<PostProps> = ({ id, entryId, author, posted, image, width,
encryptionEnabled: false,
});
}
}, [id, image, author, postState, setPostState]);
}, [id, image, author, postState, setPostState, width, height]);

// const handleSaveVisibility = () => {
// if (postState?.encryptionEnabled) {
Expand Down
34 changes: 0 additions & 34 deletions src/error-page.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/hooks/useCreateBinaryFeedImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { useMutation } from "@apollo/client";
import { CREATE_BINARYFEEDIMAGE } from "../api/api";

interface FmFileResponse {
file: any;
file: File;
data: {
id: string;
createdOn: string;
Expand Down
6 changes: 3 additions & 3 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import router from './routes.tsx';
const readApiHttpLink = createHttpLink({
uri: import.meta.env.VITE_READ_API_URL,
});

console.log("readApiHttpLink", readApiHttpLink)
const mainApiHttpLink = createHttpLink({
uri: import.meta.env.VITE_MAIN_API_URL,
});

console.log("mainApiHttpLink", mainApiHttpLink)
const manageApiHttpLink = createHttpLink({
uri: import.meta.env.VITE_MANAGE_API_URL,
});

console.log("manageApiHttpLink", manageApiHttpLink)
const cache = new InMemoryCache({
typePolicies: {
Query: {
Expand Down
6 changes: 1 addition & 5 deletions src/routes/Error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import { json, LoaderFunction, useRouteError } from "react-router-dom";
import { useRouteError } from "react-router-dom";

interface RouteError {
statusText?: string;
Expand All @@ -36,8 +36,4 @@ const Error = () => {
);
};

export const errorLoader: LoaderFunction = async () => {
return json({});
}

export default Error;
6 changes: 0 additions & 6 deletions src/routes/Faq.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";

import { json, LoaderFunction } from "react-router-dom";

/**
* The Faq component displays the frequently asked questions.
*
Expand Down Expand Up @@ -107,8 +105,4 @@ const Faq: React.FC = () => {
)
}

export const faqLoader: LoaderFunction = async () => {
return json({});
}

export default Faq
2 changes: 0 additions & 2 deletions src/routes/PostPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ const PostPage: React.FC = () => {
if (error) {
return <div>Error: {error.message}</div>;
}
if (data) {

}
if (data && data.getBinaryImagePost && data.getBinaryImagePost.data) {
const { id, entryId, author, posted, image, width, height, key } = data.getBinaryImagePost.data;
return (
Expand Down
6 changes: 1 addition & 5 deletions src/routes/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import { json, LoaderFunction, Outlet } from 'react-router-dom';
import { Outlet } from 'react-router-dom';

/**
* The main component for the root route.
Expand All @@ -34,8 +34,4 @@ const Root = () => {
);
}

export const rootLoader: LoaderFunction = async () => {
return json({});
}

export default Root;
4 changes: 3 additions & 1 deletion src/utils/encryption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ function handleDecrypt(
setDecryptedText(originalText);
decryptionSuccessful = true;
}
} catch (error) {}
} catch (error) {
throw new Error(`Error decrypting: ${error}`);
}

// Only update the UI if decryption was successful
if (decryptionSuccessful) {
Expand Down
12 changes: 12 additions & 0 deletions src/utils/loaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

import { json, LoaderFunction, LoaderFunctionArgs } from "react-router-dom";

export const rootLoader: LoaderFunction = async () => {
return json({});
};

const appLoader: LoaderFunction = async () => {
return json({});
};
Expand All @@ -39,4 +43,12 @@ export const aboutLoader: LoaderFunction = async () => {
return json({});
};

export const errorLoader: LoaderFunction = async () => {
return json({});
};

export const faqLoader: LoaderFunction = async () => {
return json({});
};

export { appLoader };

0 comments on commit 8a43043

Please sign in to comment.