From 4a273fd98a12f464274e2a1bb3c0f2ac2a48db8d Mon Sep 17 00:00:00 2001 From: KoalaSat Date: Fri, 15 Dec 2023 15:17:46 +0000 Subject: [PATCH] Avatar hashid in Garage (#983) --- frontend/src/basic/BookPage/index.tsx | 2 +- frontend/src/basic/Main.tsx | 10 +------- frontend/src/basic/MakerPage/index.tsx | 2 +- frontend/src/basic/NavBar/NavBar.tsx | 14 +++++------ frontend/src/basic/RobotPage/Onboarding.tsx | 10 ++++---- frontend/src/basic/RobotPage/RobotProfile.tsx | 23 +++++++------------ frontend/src/components/Dialogs/Profile.tsx | 10 ++++---- .../src/components/MakerForm/MakerForm.tsx | 2 +- .../components/OrderDetails/TakeButton.tsx | 2 +- frontend/src/components/RobotAvatar/index.tsx | 11 +++------ .../EncryptedSocketChat/index.tsx | 2 +- frontend/src/contexts/FederationContext.ts | 5 ++-- frontend/src/models/Garage.model.ts | 9 ++++---- frontend/src/models/Robot.model.ts | 15 ------------ frontend/src/models/Slot.model.ts | 19 ++++++++++----- 15 files changed, 53 insertions(+), 83 deletions(-) diff --git a/frontend/src/basic/BookPage/index.tsx b/frontend/src/basic/BookPage/index.tsx index 85aa695d..30b28ba9 100644 --- a/frontend/src/basic/BookPage/index.tsx +++ b/frontend/src/basic/BookPage/index.tsx @@ -31,7 +31,7 @@ const BookPage = (): JSX.Element => { const chartWidthEm = width - maxBookTableWidth; const onOrderClicked = function (id: number, shortAlias: string): void { - if (garage.getSlot()?.avatarLoaded === true) { + if (Boolean(garage.getSlot()?.hashId)) { setDelay(10000); navigate(`/order/${shortAlias}/${id}`); } else { diff --git a/frontend/src/basic/Main.tsx b/frontend/src/basic/Main.tsx index 0ba4318e..b87d564a 100644 --- a/frontend/src/basic/Main.tsx +++ b/frontend/src/basic/Main.tsx @@ -33,17 +33,9 @@ const Main: React.FC = () => { useContext(AppContext); const { garage } = useContext(GarageContext); - const onLoad = (): void => { - garage.updateSlot({ avatarLoaded: true }); - }; - return ( - + { diff --git a/frontend/src/basic/MakerPage/index.tsx b/frontend/src/basic/MakerPage/index.tsx index 8fee6249..c4f4d585 100644 --- a/frontend/src/basic/MakerPage/index.tsx +++ b/frontend/src/basic/MakerPage/index.tsx @@ -51,7 +51,7 @@ const MakerPage = (): JSX.Element => { ]); const onOrderClicked = function (id: number): void { - if (garage.getSlot()?.avatarLoaded === true) { + if (Boolean(garage.getSlot()?.hashId)) { navigate(`/order/${id}`); } else { setOpenNoRobot(true); diff --git a/frontend/src/basic/NavBar/NavBar.tsx b/frontend/src/basic/NavBar/NavBar.tsx index 3ca0f286..34cbbfaf 100644 --- a/frontend/src/basic/NavBar/NavBar.tsx +++ b/frontend/src/basic/NavBar/NavBar.tsx @@ -32,7 +32,7 @@ const NavBar = (): JSX.Element => { navbarHeight, hostUrl, } = useContext(AppContext); - const { garage, orderUpdatedAt } = useContext(GarageContext); + const { garage, orderUpdatedAt, robotUpdatedAt } = useContext(GarageContext); const navigate = useNavigate(); const location = useLocation(); @@ -42,7 +42,7 @@ const NavBar = (): JSX.Element => { const tabSx = smallBar ? { position: 'relative', - bottom: garage.getSlot()?.avatarLoaded === true ? '0.9em' : '0.13em', + bottom: Boolean(garage.getSlot()?.hashId) ? '0.9em' : '0.13em', minWidth: '1em', } : { position: 'relative', bottom: '1em', minWidth: '2em' }; @@ -65,7 +65,7 @@ const NavBar = (): JSX.Element => { if (isPage(pathPage)) { setPage(pathPage); } - }, [location, navigate, setPage, orderUpdatedAt]); + }, [location, navigate, setPage, orderUpdatedAt, robotUpdatedAt]); const handleSlideDirection = function (oldPage: Page, newPage: Page): void { const oldPos: number = pagesPosition[oldPage]; @@ -121,16 +121,16 @@ const NavBar = (): JSX.Element => { { setOpen({ ...closeAll, profile: !open.profile }); }} icon={ - slot?.getRobot()?.nickname != null && slot?.avatarLoaded ? ( + slot?.hashId ? ( ) : ( <> @@ -165,7 +165,7 @@ const NavBar = (): JSX.Element => { label={smallBar ? undefined : t('Order')} value='order' disabled={ - slot?.avatarLoaded === false || + !Boolean(slot?.hashId) || !(slot?.getRobot(slot?.activeShortAlias ?? '')?.activeOrderId != null) } icon={} diff --git a/frontend/src/basic/RobotPage/Onboarding.tsx b/frontend/src/basic/RobotPage/Onboarding.tsx index 389723aa..323dc4c5 100644 --- a/frontend/src/basic/RobotPage/Onboarding.tsx +++ b/frontend/src/basic/RobotPage/Onboarding.tsx @@ -151,7 +151,7 @@ const Onboarding = ({ - {slot?.avatarLoaded === true && Boolean(robot?.nickname) ? ( + {Boolean(slot?.hashId) ? ( t('This is your trading avatar') ) : ( <> @@ -164,7 +164,7 @@ const Onboarding = ({ - {slot?.avatarLoaded === true && Boolean(robot?.nickname) ? ( + {Boolean(slot?.hashId) ? ( {t('Hi! My name is')} @@ -198,7 +198,7 @@ const Onboarding = ({ width: '1.5em', }} /> - {robot.nickname} + {slot?.nickname} ) : null} - +