Skip to content

Commit

Permalink
Fix socket (#160)
Browse files Browse the repository at this point in the history
* set up socket-package

* new socket working
  • Loading branch information
prtkjakhar authored Sep 1, 2023
1 parent b67f17e commit 6d4c006
Show file tree
Hide file tree
Showing 8 changed files with 19,920 additions and 15,977 deletions.
1 change: 1 addition & 0 deletions apps/amakrushi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"react-router-dom": "^6.3.0",
"react-scripts": "5.0.0",
"react-toastify": "^9.0.5",
"socket-package": "0.13.0",
"socket.io-client": "^4.5.1",
"typescript": "^4.9.3",
"underscore": "^1.13.6",
Expand Down
16 changes: 2 additions & 14 deletions apps/amakrushi/src/components/HomePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const HomePage: NextPage = () => {
transliteratedArray.push(element?.target?.[0]);
}

if (context?.socketSession && context?.newSocket?.connected) {
if (context?.newSocket?.socket?.connected) {
console.log("clearing mssgs");
context?.setMessages([]);
router.push("/chat");
Expand All @@ -103,7 +103,7 @@ const HomePage: NextPage = () => {
return;
}
} else {
if (context?.socketSession && context?.newSocket?.connected) {
if (context?.newSocket?.socket?.connected) {
console.log("clearing mssgs");
context?.setMessages([]);
router.push("/chat");
Expand All @@ -123,18 +123,6 @@ const HomePage: NextPage = () => {
return (
<>
<div className={styles.main}>
{/* {!(context?.socketSession && context?.newSocket?.connected) && (
<div className={styles.disconnected}>
<p>You are disconnected &nbsp;</p>
<div
onClick={() => {
context?.onSocketConnect({text: ""});
}}
>
<Image src={reloadIcon} alt="reloadIcon" width={24} height={24}/>
</div>
</div>
)} */}
<div className={styles.title}>{t('label.ask_me')}</div>
<div
className={
Expand Down
4 changes: 2 additions & 2 deletions apps/amakrushi/src/components/OTPpage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ const OTPpage: React.FC = () => {
// @ts-ignore
setUserId(analytics, localStorage.getItem("userID"));

context?.setIsMobileAvailable(true);
setTimeout(() => {
router.push("/");
}, 10);
Expand Down Expand Up @@ -154,7 +153,7 @@ const OTPpage: React.FC = () => {
} else {
toast.error(`${t("error.otp_not_sent")}`);
}
} catch (error) {
} catch (error: any) {
toast.error(`${t("error.error.sending_otp")}`);
//@ts-ignore
logEvent(analytics, 'console_error', {
Expand Down Expand Up @@ -206,6 +205,7 @@ const OTPpage: React.FC = () => {
<b>+91-{router.query.state}</b>
</div>
<form onSubmit={handleOTPSubmit}>
{/* @ts-ignore */}
<HStack style={{ marginTop: "34px", justifyContent: "center" }}>
<PinInput otp placeholder="">
<PinInputField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const ChatUiWindow: React.FC = () => {
transliteratedArray.push(element?.target?.[0]);
}

if (context?.socketSession && context?.newSocket?.connected) {
if (context?.newSocket?.socket?.connected) {
context?.sendMessage(transliteratedArray.join(" "));
} else {
toast.error(t("error.disconnected"));
Expand Down
Loading

0 comments on commit 6d4c006

Please sign in to comment.