From a2d4fea04c167bb13a932b547bef9c7df931e044 Mon Sep 17 00:00:00 2001 From: koalasat Date: Fri, 11 Jul 2025 09:30:41 +0200 Subject: [PATCH] Finally fix RobotAvatar --- frontend/src/components/Dialogs/GoToOrder.tsx | 40 +++++++-------- frontend/src/components/Dialogs/Profile.tsx | 49 +++++++----------- frontend/src/components/RobotAvatar/index.tsx | 50 +++++++++++-------- frontend/static/locales/ca.json | 1 - frontend/static/locales/cs.json | 1 - frontend/static/locales/de.json | 1 - frontend/static/locales/en.json | 1 - frontend/static/locales/es.json | 1 - frontend/static/locales/eu.json | 1 - frontend/static/locales/fr.json | 1 - frontend/static/locales/it.json | 1 - frontend/static/locales/ja.json | 1 - frontend/static/locales/pl.json | 1 - frontend/static/locales/pt.json | 1 - frontend/static/locales/ru.json | 1 - frontend/static/locales/sv.json | 1 - frontend/static/locales/sw.json | 1 - frontend/static/locales/th.json | 1 - frontend/static/locales/zh-SI.json | 1 - frontend/static/locales/zh-TR.json | 1 - 20 files changed, 67 insertions(+), 89 deletions(-) diff --git a/frontend/src/components/Dialogs/GoToOrder.tsx b/frontend/src/components/Dialogs/GoToOrder.tsx index 7f5eacb1..b749e41b 100644 --- a/frontend/src/components/Dialogs/GoToOrder.tsx +++ b/frontend/src/components/Dialogs/GoToOrder.tsx @@ -7,9 +7,9 @@ import { DialogContent, DialogContentText, Button, - Grid, TextField, useTheme, + Typography, } from '@mui/material'; import { useNavigate } from 'react-router-dom'; @@ -46,27 +46,27 @@ const GoToOrder = ({ open, onClose }: Props): React.JSX.Element => { {t('Search order')} - {t("Enter here an order URL to search for it, even if it's password protected")} + + {t("Enter here an order URL to search for it, even if it's password protected")} + - - setOrderUrl(e.target.value)} - /> - + setOrderUrl(e.target.value)} + /> diff --git a/frontend/src/components/Dialogs/Profile.tsx b/frontend/src/components/Dialogs/Profile.tsx index e9cb224c..21aaf051 100644 --- a/frontend/src/components/Dialogs/Profile.tsx +++ b/frontend/src/components/Dialogs/Profile.tsx @@ -30,18 +30,14 @@ const ProfileDialog = ({ open = false, onClose }: Props): React.JSX.Element => { const { garage, slotUpdatedAt } = useContext(GarageContext); const { t } = useTranslation(); - const slot = garage.getSlot(); - const [loading, setLoading] = useState(true); - const [loadingRobots, setLoadingRobots] = useState( - Object.values(slot?.robots ?? {}).length, - ); useEffect(() => { setLoading(!garage.getSlot()?.hashId); - setLoadingRobots(Object.values(slot?.robots ?? {}).filter((robot) => robot.loading).length); }, [slotUpdatedAt]); + const slot = garage.getSlot(); + return ( { - {!garage.getSlot()?.nickname && ( -
- - - {loadingRobots > 0 ? ( - <> - {t('Looking for your robot!')} - - - ) : ( - <> - )} diff --git a/frontend/src/components/RobotAvatar/index.tsx b/frontend/src/components/RobotAvatar/index.tsx index a3814a1c..6f4f568a 100644 --- a/frontend/src/components/RobotAvatar/index.tsx +++ b/frontend/src/components/RobotAvatar/index.tsx @@ -46,42 +46,52 @@ const RobotAvatar: React.FC = ({ imageStyle = {}, onLoad = () => {}, }) => { - const { hostUrl, client } = useContext(AppContext); - const defaultAvatarSrc = useMemo(() => { - return client !== 'mobile' - ? `${hostUrl}/static/federation/avatars/${shortAlias}${small ? '.small' : ''}.webp` - : `file:///android_asset/Web.bundle/assets/federation/avatars/${shortAlias}.webp`; - }, [shortAlias, small]); - - const [avatarSrc, setAvatarSrc] = useState(defaultAvatarSrc); - const [activeBackground, setActiveBackground] = useState(true); + const backgroundFadeTime = 3000; const [backgroundData] = useState(placeholder.loading); - const backgroundImage = `url(data:${backgroundData.mime};base64,${backgroundData.data})`; + const { hostUrl, client } = useContext(AppContext); + const [avatarSrc, setAvatarSrc] = useState(); + const [activeBackground, setActiveBackground] = useState(true); + const className = placeholderType === 'loading' ? 'loadingAvatar' : 'generatingAvatar'; useEffect(() => { if (hashId) { - roboidentitiesClient - .generateRobohash(hashId, small ? 'small' : 'large') - .then((avatar) => { - setAvatarSrc(avatar); - setActiveBackground(false); - }) - .catch(() => { - setActiveBackground(true); - }); + generateAvatar(); + + setTimeout(() => { + if (!avatarSrc) generateAvatar(); + }, backgroundFadeTime); } }, [hashId, small]); useEffect(() => { if (shortAlias && shortAlias !== '') { - setAvatarSrc(defaultAvatarSrc); + const coordinatorAvatar = + client !== 'mobile' + ? `${hostUrl}/static/federation/avatars/${shortAlias}${small ? '.small' : ''}.webp` + : `file:///android_asset/Web.bundle/assets/federation/avatars/${shortAlias}.webp`; + setAvatarSrc(coordinatorAvatar); } else { setActiveBackground(true); } }, [shortAlias]); + const generateAvatar = () => { + if (!hashId) return; + + roboidentitiesClient + .generateRobohash(hashId, small ? 'small' : 'large') + .then((avatar) => { + setAvatarSrc(avatar); + setActiveBackground(false); + }) + .catch(() => { + console.log('CATCH'); + setActiveBackground(true); + }); + }; + const statusBadge = (
{orderType === 0 ? ( diff --git a/frontend/static/locales/ca.json b/frontend/static/locales/ca.json index 28c8ae5c..1166a089 100644 --- a/frontend/static/locales/ca.json +++ b/frontend/static/locales/ca.json @@ -329,7 +329,6 @@ "You do not have a robot avatar": "No tens un avatar robot", "#32": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinadors que coneixen el teu robot:", - "Looking for your robot!": "Buscant el teu robot!", "Your Robot": "El teu Robot", "#33": "Phrases in components/Dialogs/Recovery.tsx", "Enter your robot token to re-build your robot and gain access to its trades.": "Introdueix el teu token per reconstruir el teu robot i accedir a les seves operacions.", diff --git a/frontend/static/locales/cs.json b/frontend/static/locales/cs.json index 6330caac..480e544c 100644 --- a/frontend/static/locales/cs.json +++ b/frontend/static/locales/cs.json @@ -329,7 +329,6 @@ "You do not have a robot avatar": "Nemáš robota a avatar", "#32": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", - "Looking for your robot!": "Looking for your robot!", "Your Robot": "Your Robot", "#33": "Phrases in components/Dialogs/Recovery.tsx", "Enter your robot token to re-build your robot and gain access to its trades.": "Enter your robot token to re-build your robot and gain access to its trades.", diff --git a/frontend/static/locales/de.json b/frontend/static/locales/de.json index 8b4f11dd..ea7589f5 100644 --- a/frontend/static/locales/de.json +++ b/frontend/static/locales/de.json @@ -329,7 +329,6 @@ "You do not have a robot avatar": "Du hast keinen Roboter-Avatar", "#32": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", - "Looking for your robot!": "Looking for your robot!", "Your Robot": "Your Robot", "#33": "Phrases in components/Dialogs/Recovery.tsx", "Enter your robot token to re-build your robot and gain access to its trades.": "Enter your robot token to re-build your robot and gain access to its trades.", diff --git a/frontend/static/locales/en.json b/frontend/static/locales/en.json index 9bf67d9d..ef7fdab5 100644 --- a/frontend/static/locales/en.json +++ b/frontend/static/locales/en.json @@ -329,7 +329,6 @@ "You do not have a robot avatar": "You do not have a robot avatar", "#32": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", - "Looking for your robot!": "Looking for your robot!", "Your Robot": "Your Robot", "#33": "Phrases in components/Dialogs/Recovery.tsx", "Enter your robot token to re-build your robot and gain access to its trades.": "Enter your robot token to re-build your robot and gain access to its trades.", diff --git a/frontend/static/locales/es.json b/frontend/static/locales/es.json index 3a8f52db..c1a16a8c 100644 --- a/frontend/static/locales/es.json +++ b/frontend/static/locales/es.json @@ -329,7 +329,6 @@ "You do not have a robot avatar": "No tienes un avatar robot", "#32": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", - "Looking for your robot!": "Looking for your robot!", "Your Robot": "Your Robot", "#33": "Phrases in components/Dialogs/Recovery.tsx", "Enter your robot token to re-build your robot and gain access to its trades.": "Escribe o pega el token de tu robot token para reconstruirlo y acceder a tus operaciones.", diff --git a/frontend/static/locales/eu.json b/frontend/static/locales/eu.json index 10ab4031..e24926a8 100644 --- a/frontend/static/locales/eu.json +++ b/frontend/static/locales/eu.json @@ -329,7 +329,6 @@ "You do not have a robot avatar": "Ez daukazu robot avatarrik", "#32": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", - "Looking for your robot!": "Looking for your robot!", "Your Robot": "Your Robot", "#33": "Phrases in components/Dialogs/Recovery.tsx", "Enter your robot token to re-build your robot and gain access to its trades.": "Enter your robot token to re-build your robot and gain access to its trades.", diff --git a/frontend/static/locales/fr.json b/frontend/static/locales/fr.json index 06ec53a8..f7ad322f 100644 --- a/frontend/static/locales/fr.json +++ b/frontend/static/locales/fr.json @@ -329,7 +329,6 @@ "You do not have a robot avatar": "Vous n'avez pas d'avatar robot", "#32": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", - "Looking for your robot!": "Looking for your robot!", "Your Robot": "Votre Robot", "#33": "Phrases in components/Dialogs/Recovery.tsx", "Enter your robot token to re-build your robot and gain access to its trades.": "Saisissez votre jeton de robot pour reconstruire votre robot et accéder à ses transactions.", diff --git a/frontend/static/locales/it.json b/frontend/static/locales/it.json index fec50a20..ea419ced 100644 --- a/frontend/static/locales/it.json +++ b/frontend/static/locales/it.json @@ -329,7 +329,6 @@ "You do not have a robot avatar": "Non hai un avatar per il tuo robot", "#32": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", - "Looking for your robot!": "Looking for your robot!", "Your Robot": "Il tuo Robot", "#33": "Phrases in components/Dialogs/Recovery.tsx", "Enter your robot token to re-build your robot and gain access to its trades.": "Inserisci il token del tuo robot per ricostruirlo ed ottenere l'accesso ai suoi scambi.", diff --git a/frontend/static/locales/ja.json b/frontend/static/locales/ja.json index 05d3b650..46a74535 100644 --- a/frontend/static/locales/ja.json +++ b/frontend/static/locales/ja.json @@ -329,7 +329,6 @@ "You do not have a robot avatar": "ロボットのアバターがありません", "#32": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", - "Looking for your robot!": "Looking for your robot!", "Your Robot": "Your Robot", "#33": "Phrases in components/Dialogs/Recovery.tsx", "Enter your robot token to re-build your robot and gain access to its trades.": "取引にアクセスするために、ロボットのトークンを入力してロボットを再生成してください。", diff --git a/frontend/static/locales/pl.json b/frontend/static/locales/pl.json index 8cc3ad95..abbd51db 100644 --- a/frontend/static/locales/pl.json +++ b/frontend/static/locales/pl.json @@ -329,7 +329,6 @@ "You do not have a robot avatar": "You do not have a robot avatar", "#32": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", - "Looking for your robot!": "Looking for your robot!", "Your Robot": "Your Robot", "#33": "Phrases in components/Dialogs/Recovery.tsx", "Enter your robot token to re-build your robot and gain access to its trades.": "Enter your robot token to re-build your robot and gain access to its trades.", diff --git a/frontend/static/locales/pt.json b/frontend/static/locales/pt.json index 8fbffcab..46a4dd3b 100644 --- a/frontend/static/locales/pt.json +++ b/frontend/static/locales/pt.json @@ -329,7 +329,6 @@ "You do not have a robot avatar": "Você não tem um avatar de robô", "#32": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", - "Looking for your robot!": "Procurando pelo seu robô!", "Your Robot": "Seu Robô", "#33": "Phrases in components/Dialogs/Recovery.tsx", "Enter your robot token to re-build your robot and gain access to its trades.": "Entre com seu token de robô para reconstruir seu robô e ganhar acesso às suas negociações.", diff --git a/frontend/static/locales/ru.json b/frontend/static/locales/ru.json index faf0f819..7177ff12 100644 --- a/frontend/static/locales/ru.json +++ b/frontend/static/locales/ru.json @@ -329,7 +329,6 @@ "You do not have a robot avatar": "У Вас нет аватара робота", "#32": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", - "Looking for your robot!": "Looking for your robot!", "Your Robot": "Ваш Robot", "#33": "Phrases in components/Dialogs/Recovery.tsx", "Enter your robot token to re-build your robot and gain access to its trades.": "Введите токен своего робота, чтобы восстанавить своего робота и получить доступ к его сделкам.", diff --git a/frontend/static/locales/sv.json b/frontend/static/locales/sv.json index 578ae66b..e106eca0 100644 --- a/frontend/static/locales/sv.json +++ b/frontend/static/locales/sv.json @@ -329,7 +329,6 @@ "You do not have a robot avatar": "Du har ingen robotavatar", "#32": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", - "Looking for your robot!": "Looking for your robot!", "Your Robot": "Your Robot", "#33": "Phrases in components/Dialogs/Recovery.tsx", "Enter your robot token to re-build your robot and gain access to its trades.": "Enter your robot token to re-build your robot and gain access to its trades.", diff --git a/frontend/static/locales/sw.json b/frontend/static/locales/sw.json index 664a3fdd..d05557d1 100644 --- a/frontend/static/locales/sw.json +++ b/frontend/static/locales/sw.json @@ -329,7 +329,6 @@ "You do not have a robot avatar": "Huna picha ya mwakilishi wa roboti", "#32": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", - "Looking for your robot!": "Looking for your robot!", "Your Robot": "Roboti yako", "#33": "Phrases in components/Dialogs/Recovery.tsx", "Enter your robot token to re-build your robot and gain access to its trades.": "Ingiza alama ya roboti yako ili kuirekebisha roboti yako na kupata ufikiaji wa biashara zake.", diff --git a/frontend/static/locales/th.json b/frontend/static/locales/th.json index de4bb99d..08e84252 100644 --- a/frontend/static/locales/th.json +++ b/frontend/static/locales/th.json @@ -329,7 +329,6 @@ "You do not have a robot avatar": "คุณไม่มีโรบอท", "#32": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", - "Looking for your robot!": "Looking for your robot!", "Your Robot": "Your Robot", "#33": "Phrases in components/Dialogs/Recovery.tsx", "Enter your robot token to re-build your robot and gain access to its trades.": "Enter your robot token to re-build your robot and gain access to its trades.", diff --git a/frontend/static/locales/zh-SI.json b/frontend/static/locales/zh-SI.json index 844e1336..801549f4 100644 --- a/frontend/static/locales/zh-SI.json +++ b/frontend/static/locales/zh-SI.json @@ -329,7 +329,6 @@ "You do not have a robot avatar": "你没有机器人头像", "#32": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", - "Looking for your robot!": "Looking for your robot!", "Your Robot": "你的机器人", "#33": "Phrases in components/Dialogs/Recovery.tsx", "Enter your robot token to re-build your robot and gain access to its trades.": "输入你的机器人令牌来重造你的机器人并访问它的交易。", diff --git a/frontend/static/locales/zh-TR.json b/frontend/static/locales/zh-TR.json index f6d68fb1..e638f13c 100644 --- a/frontend/static/locales/zh-TR.json +++ b/frontend/static/locales/zh-TR.json @@ -329,7 +329,6 @@ "You do not have a robot avatar": "你沒有機器人頭像", "#32": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", - "Looking for your robot!": "Looking for your robot!", "Your Robot": "你的機器人", "#33": "Phrases in components/Dialogs/Recovery.tsx", "Enter your robot token to re-build your robot and gain access to its trades.": "輸入你的機器人領牌來重造你的機器人並訪問它的交易。",