Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect to root page if chat id not found #194

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions frontend/src/components/Conversation/Conversation.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import {
useEffect,
useRef,
useState,
// useState
} from "react";
import { useEffect, useRef, useState } from "react";
import { isAxiosError } from "axios";
import { Message } from "./Message";
import { Navigate, useParams } from "react-router-dom";
import ExpandingInput from "./ExpandingInput";
Expand Down Expand Up @@ -113,20 +109,22 @@ export const Conversation = () => {
</div>
);
}

if (
(isAxiosError(getMessagesError) &&
getMessagesError.response?.status === 404) ||
!connectionsData?.connections?.length
) {
return <Navigate to={Routes.Root} />;
}

if (!isSuccessGetMessages) {
return (
<div className="w-full h-screen flex justify-center items-center text-white">
Something went wrong!
</div>
);
}
if (
// @ts-expect-error, status is not known
getMessagesError?.status === 404 ||
!connectionsData?.connections?.length
) {
return <Navigate to={Routes.Root} />;
}

return (
<div className="bg-gray-900 w-full h-[calc(100%-4rem)] relative flex flex-col">
Expand Down
Loading