Skip to content

Commit

Permalink
Revert "Error Handling Updated"
Browse files Browse the repository at this point in the history
This reverts commit 6245a8e.
  • Loading branch information
The-XENO-Studios committed Aug 17, 2024
1 parent d938dd3 commit b277c9f
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 155 deletions.
135 changes: 71 additions & 64 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"dotenv": "^16.3.1",
"express": "^4.19.2",
"framer-motion": "^10.16.5",
"next": "^14.2.5",
"next": "14.0.2",
"nextjs-toploader": "^1.6.4",
"nodemailer": "^6.9.7",
"react": "^18",
Expand Down
22 changes: 5 additions & 17 deletions src/app/Components/HashtechPosts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,18 @@ interface Props {
redirectUrl: string;
}

async function getData(imageCode: any) {
const HashtechPosts = async ({ title, desc, redirectUrl }: Props) => {
let regex = /fbid=(\d+)&/;
let imageCode = redirectUrl.match(regex);

const res = await fetch(
imageCode
? `https://hashtechimg.pythonanywhere.com/${imageCode[1]}?size=360`
: "https://hashtechimg.pythonanywhere.com/874301847421348?size=360",
{ cache: "no-store" }
);

if (!res.ok) {
return "/Logo.png";
} else {
return res.url;
}
}

const HashtechPosts = async ({ title, desc, redirectUrl }: Props) => {
let regex = /fbid=(\d+)&/;
let imageCode = redirectUrl.match(regex);

let imgURL = "";

try {
imgURL = await getData(imageCode);
} catch (error) {}
const imgURL = await res.url;

// const inView = useInView(ref, { once: true });
return (
Expand Down
25 changes: 5 additions & 20 deletions src/app/Components/Sidebar/NewNotification.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
import SaveData from "./SaveData";

async function getData() {
const NewNotification = async () => {
let data = [];
const res = await fetch(
"https://nditc.pythonanywhere.com/api/v1/notifications/web?page=1&limit=1",
{ cache: "no-store" }
);

if (!res.ok) {
return [];
} else {
return res.json();
}
}

const NewNotification = async () => {
let data: any[] = [];
try {
data = await getData();
} catch (error) {
console.log("Error");
if (res.ok) {
data = await res.json();
}

if (data.length != 0) {
<SaveData data={data} />;
} else {
return <div></div>;
}
return <SaveData data={data} />;
};

export default NewNotification;
7 changes: 2 additions & 5 deletions src/app/Components/Sidebar/SaveData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ import Link from "next/link";
import { useEffect, useState } from "react";

const SaveData = ({ data }: { data: any }) => {
const detailsEncrypt = AES.encrypt(
data.length != 0 ? data[0].details_url : "OOOPS",
"Anime"
);
const detailsEncrypt = AES.encrypt(data[0].details_url, "Anime");
const [isNew, setIsNew] = useState(false);

const NewNotification = JSON.stringify(data[0]?.title);
const NewNotification = JSON.stringify(data[0].title);

useEffect(() => {
const savedNotification = localStorage.getItem("latestNotification");
Expand Down
Loading

0 comments on commit b277c9f

Please sign in to comment.