Fix too-many fetchRobots and coordinator endpoints print

This commit is contained in:
Reckless_Satoshi 2024-01-14 18:20:48 +00:00
parent c98e643645
commit 27b265220e
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
24 changed files with 53 additions and 41 deletions

View File

@ -83,7 +83,6 @@ const MainDialogs = (): JSX.Element => {
/> />
<ProfileDialog <ProfileDialog
open={open.profile} open={open.profile}
baseUrl={hostUrl}
onClose={() => { onClose={() => {
setOpen({ ...open, profile: false }); setOpen({ ...open, profile: false });
}} }}

View File

@ -42,7 +42,7 @@ const RobotPage = (): JSX.Element => {
useEffect(() => { useEffect(() => {
const token = urlToken ?? garage.currentSlot; const token = urlToken ?? garage.currentSlot;
if (token !== undefined && token !== null) { if (token !== undefined && token !== null && page === 'robot') {
setInputToken(token); setInputToken(token);
if (window.NativeRobosats === undefined || torStatus === '"Done"') { if (window.NativeRobosats === undefined || torStatus === '"Done"') {
getGenerateRobot(token); getGenerateRobot(token);

View File

@ -635,13 +635,28 @@ const CoordinatorDialog = ({ open = false, onClose, network, shortAlias }: Props
<ListItemIcon> <ListItemIcon>
<Dns /> <Dns />
</ListItemIcon> </ListItemIcon>
<ListItemText secondary={t('Coordinator domain')}> <ListItemText
secondary={t('Coordinator domain')}
primaryTypographyProps={{
style: {
maxWidth: '20em',
wordWrap: 'break-word',
overflowWrap: 'break-word',
},
}}
>
<Link <Link
target='_blank' target='_blank'
href={coordinator?.[settings.network][origin]} href={
coordinator?.[settings.network][
settings.selfhostedClient ? 'onion' : origin
]
}
rel='noreferrer' rel='noreferrer'
> >
{`${coordinator?.[settings.network][origin]}`} {`${coordinator?.[settings.network][
settings.selfhostedClient ? 'onion' : origin
]}`}
</Link> </Link>
</ListItemText> </ListItemText>
</ListItem> </ListItem>

View File

@ -23,10 +23,9 @@ import { type Coordinator } from '../../models';
interface Props { interface Props {
open: boolean; open: boolean;
onClose: () => void; onClose: () => void;
baseUrl: string;
} }
const ProfileDialog = ({ open = false, baseUrl, onClose }: Props): JSX.Element => { const ProfileDialog = ({ open = false, onClose }: Props): JSX.Element => {
const { federation } = useContext<UseFederationStoreType>(FederationContext); const { federation } = useContext<UseFederationStoreType>(FederationContext);
const { garage, robotUpdatedAt } = useContext<UseGarageStoreType>(GarageContext); const { garage, robotUpdatedAt } = useContext<UseGarageStoreType>(GarageContext);
const { t } = useTranslation(); const { t } = useTranslation();
@ -92,7 +91,7 @@ const ProfileDialog = ({ open = false, baseUrl, onClose }: Props): JSX.Element =
</List> </List>
<Typography> <Typography>
<b>{t('Coordinators that know your robots')}</b> <b>{t('Coordinators that know your robot:')}</b>
</Typography> </Typography>
{Object.values(federation.coordinators).map((coordinator: Coordinator): JSX.Element => { {Object.values(federation.coordinators).map((coordinator: Coordinator): JSX.Element => {

View File

@ -92,8 +92,9 @@ const MakerForm = ({
const amountSafeThresholds = [1.03, 0.98]; const amountSafeThresholds = [1.03, 0.98];
useEffect(() => { useEffect(() => {
const slot = garage.getSlot(); // Why?
if (slot?.token) void federation.fetchRobot(garage, slot?.token); // const slot = garage.getSlot();
// if (slot?.token) void federation.fetchRobot(garage, slot?.token);
}, [garage.currentSlot]); }, [garage.currentSlot]);
useEffect(() => { useEffect(() => {

View File

@ -148,16 +148,22 @@ export const FederationContextProvider = ({
if (page === 'offers') void federation.updateBook(); if (page === 'offers') void federation.updateBook();
}, [page]); }, [page]);
// use effects to fetchRobots on app start and network change
useEffect(() => { useEffect(() => {
const slot = garage.getSlot(); const slot = garage.getSlot();
const robot = slot?.getRobot(); const robot = slot?.getRobot();
if (robot && garage.currentSlot) { if (robot && garage.currentSlot && slot?.token && robot.encPrivKey && robot.pubKey) {
if (open.profile && Boolean(slot?.hashId) && slot?.token) { void federation.fetchRobot(garage, slot.token);
void federation.fetchRobot(garage, slot?.token); // refresh/update existing robot }
} else if (slot?.token && robot.encPrivKey && robot.pubKey) { }, [settings.network]);
void federation.fetchRobot(garage, slot.token); // create new robot with existing token and keys (on network and coordinator change) // use effects to fetchRobots on Profile open
} useEffect(() => {
const slot = garage.getSlot();
const robot = slot?.getRobot();
if (open.profile && slot?.hashId && slot?.token) {
void federation.fetchRobot(garage, slot?.token); // refresh/update existing robot
} }
}, [open.profile]); }, [open.profile]);

View File

@ -74,14 +74,6 @@ export interface Origins {
i2p: Origin | undefined; i2p: Origin | undefined;
} }
export interface getEndpointProps {
coordinator: Coordinator;
network: 'mainnet' | 'testnet';
origin: Origin;
selfHosted: boolean;
hostUrl: string;
}
export class Coordinator { export class Coordinator {
constructor(value: any) { constructor(value: any) {
this.longAlias = value.longAlias; this.longAlias = value.longAlias;

View File

@ -305,7 +305,7 @@
"Generate a robot avatar first. Then create your own order.": "Primer genera un avatar de robot. A continuació, crea la teva pròpia oferta.", "Generate a robot avatar first. Then create your own order.": "Primer genera un avatar de robot. A continuació, crea la teva pròpia oferta.",
"You do not have a robot avatar": "No tens un avatar robot", "You do not have a robot avatar": "No tens un avatar robot",
"#29": "Phrases in components/Dialogs/Profile.tsx", "#29": "Phrases in components/Dialogs/Profile.tsx",
"Coordinators that know your robots": "Coordinators that know your robots", "Coordinators that know your robot:": "Coordinators that know your robot:",
"Your Robot": "El teu Robot", "Your Robot": "El teu Robot",
"Your robot": "El teu robot", "Your robot": "El teu robot",
"#30": "Phrases in components/Dialogs/StoreToken.tsx", "#30": "Phrases in components/Dialogs/StoreToken.tsx",

View File

@ -305,7 +305,7 @@
"Generate a robot avatar first. Then create your own order.": "Generate a robot avatar first. Then create your own order.", "Generate a robot avatar first. Then create your own order.": "Generate a robot avatar first. Then create your own order.",
"You do not have a robot avatar": "Nemáš robota a avatar", "You do not have a robot avatar": "Nemáš robota a avatar",
"#29": "Phrases in components/Dialogs/Profile.tsx", "#29": "Phrases in components/Dialogs/Profile.tsx",
"Coordinators that know your robots": "Coordinators that know your robots", "Coordinators that know your robot:": "Coordinators that know your robot:",
"Your Robot": "Your Robot", "Your Robot": "Your Robot",
"Your robot": "Tvůj robot", "Your robot": "Tvůj robot",
"#30": "Phrases in components/Dialogs/StoreToken.tsx", "#30": "Phrases in components/Dialogs/StoreToken.tsx",

View File

@ -305,7 +305,7 @@
"Generate a robot avatar first. Then create your own order.": "Generate a robot avatar first. Then create your own order.", "Generate a robot avatar first. Then create your own order.": "Generate a robot avatar first. Then create your own order.",
"You do not have a robot avatar": "Du hast keinen Roboter-Avatar", "You do not have a robot avatar": "Du hast keinen Roboter-Avatar",
"#29": "Phrases in components/Dialogs/Profile.tsx", "#29": "Phrases in components/Dialogs/Profile.tsx",
"Coordinators that know your robots": "Coordinators that know your robots", "Coordinators that know your robot:": "Coordinators that know your robot:",
"Your Robot": "Your Robot", "Your Robot": "Your Robot",
"Your robot": "Dein Roboter", "Your robot": "Dein Roboter",
"#30": "Phrases in components/Dialogs/StoreToken.tsx", "#30": "Phrases in components/Dialogs/StoreToken.tsx",

View File

@ -305,7 +305,7 @@
"Generate a robot avatar first. Then create your own order.": "Generate a robot avatar first. Then create your own order.", "Generate a robot avatar first. Then create your own order.": "Generate a robot avatar first. Then create your own order.",
"You do not have a robot avatar": "You do not have a robot avatar", "You do not have a robot avatar": "You do not have a robot avatar",
"#29": "Phrases in components/Dialogs/Profile.tsx", "#29": "Phrases in components/Dialogs/Profile.tsx",
"Coordinators that know your robots": "Coordinators that know your robots", "Coordinators that know your robot:": "Coordinators that know your robot:",
"Your Robot": "Your Robot", "Your Robot": "Your Robot",
"Your robot": "Your robot", "Your robot": "Your robot",
"#30": "Phrases in components/Dialogs/StoreToken.tsx", "#30": "Phrases in components/Dialogs/StoreToken.tsx",

View File

@ -305,7 +305,7 @@
"Generate a robot avatar first. Then create your own order.": "Primero genera un robot avatar. Después crea tu propia orden.", "Generate a robot avatar first. Then create your own order.": "Primero genera un robot avatar. Después crea tu propia orden.",
"You do not have a robot avatar": "No tienes un avatar robot", "You do not have a robot avatar": "No tienes un avatar robot",
"#29": "Phrases in components/Dialogs/Profile.tsx", "#29": "Phrases in components/Dialogs/Profile.tsx",
"Coordinators that know your robots": "Coordinators that know your robots", "Coordinators that know your robot:": "Coordinators that know your robot:",
"Your Robot": "Your Robot", "Your Robot": "Your Robot",
"Your robot": "Tu Robot", "Your robot": "Tu Robot",
"#30": "Phrases in components/Dialogs/StoreToken.tsx", "#30": "Phrases in components/Dialogs/StoreToken.tsx",

View File

@ -305,7 +305,7 @@
"Generate a robot avatar first. Then create your own order.": "Generate a robot avatar first. Then create your own order.", "Generate a robot avatar first. Then create your own order.": "Generate a robot avatar first. Then create your own order.",
"You do not have a robot avatar": "Ez daukazu robot avatarrik", "You do not have a robot avatar": "Ez daukazu robot avatarrik",
"#29": "Phrases in components/Dialogs/Profile.tsx", "#29": "Phrases in components/Dialogs/Profile.tsx",
"Coordinators that know your robots": "Coordinators that know your robots", "Coordinators that know your robot:": "Coordinators that know your robot:",
"Your Robot": "Your Robot", "Your Robot": "Your Robot",
"Your robot": "Zure robota", "Your robot": "Zure robota",
"#30": "Phrases in components/Dialogs/StoreToken.tsx", "#30": "Phrases in components/Dialogs/StoreToken.tsx",

View File

@ -305,7 +305,7 @@
"Generate a robot avatar first. Then create your own order.": "Créez d'abord un avatar de robot. Créez ensuite votre propre commande.", "Generate a robot avatar first. Then create your own order.": "Créez d'abord un avatar de robot. Créez ensuite votre propre commande.",
"You do not have a robot avatar": "Vous n'avez pas d'avatar robot", "You do not have a robot avatar": "Vous n'avez pas d'avatar robot",
"#29": "Phrases in components/Dialogs/Profile.tsx", "#29": "Phrases in components/Dialogs/Profile.tsx",
"Coordinators that know your robots": "Coordinators that know your robots", "Coordinators that know your robot:": "Coordinators that know your robot:",
"Your Robot": "Votre Robot", "Your Robot": "Votre Robot",
"Your robot": "Votre robot", "Your robot": "Votre robot",
"#30": "Phrases in components/Dialogs/StoreToken.tsx", "#30": "Phrases in components/Dialogs/StoreToken.tsx",

View File

@ -305,7 +305,7 @@
"Generate a robot avatar first. Then create your own order.": "Genera prima un avatar robot. Poi crea il tuo ordine.", "Generate a robot avatar first. Then create your own order.": "Genera prima un avatar robot. Poi crea il tuo ordine.",
"You do not have a robot avatar": "Non hai un avatar robot", "You do not have a robot avatar": "Non hai un avatar robot",
"#29": "Phrases in components/Dialogs/Profile.tsx", "#29": "Phrases in components/Dialogs/Profile.tsx",
"Coordinators that know your robots": "Coordinators that know your robots", "Coordinators that know your robot:": "Coordinators that know your robot:",
"Your Robot": "Il tuo Robot", "Your Robot": "Il tuo Robot",
"Your robot": "Il tuo robot", "Your robot": "Il tuo robot",
"#30": "Phrases in components/Dialogs/StoreToken.tsx", "#30": "Phrases in components/Dialogs/StoreToken.tsx",

View File

@ -305,7 +305,7 @@
"Generate a robot avatar first. Then create your own order.": "最初にロボットアバターを生成してください。次に自分のオーダーを作成してください。", "Generate a robot avatar first. Then create your own order.": "最初にロボットアバターを生成してください。次に自分のオーダーを作成してください。",
"You do not have a robot avatar": "ロボットのアバターがありません", "You do not have a robot avatar": "ロボットのアバターがありません",
"#29": "Phrases in components/Dialogs/Profile.tsx", "#29": "Phrases in components/Dialogs/Profile.tsx",
"Coordinators that know your robots": "Coordinators that know your robots", "Coordinators that know your robot:": "Coordinators that know your robot:",
"Your Robot": "Your Robot", "Your Robot": "Your Robot",
"Your robot": "あなたのロボット", "Your robot": "あなたのロボット",
"#30": "Phrases in components/Dialogs/StoreToken.tsx", "#30": "Phrases in components/Dialogs/StoreToken.tsx",

View File

@ -305,7 +305,7 @@
"Generate a robot avatar first. Then create your own order.": "Generate a robot avatar first. Then create your own order.", "Generate a robot avatar first. Then create your own order.": "Generate a robot avatar first. Then create your own order.",
"You do not have a robot avatar": "You do not have a robot avatar", "You do not have a robot avatar": "You do not have a robot avatar",
"#29": "Phrases in components/Dialogs/Profile.tsx", "#29": "Phrases in components/Dialogs/Profile.tsx",
"Coordinators that know your robots": "Coordinators that know your robots", "Coordinators that know your robot:": "Coordinators that know your robot:",
"Your Robot": "Your Robot", "Your Robot": "Your Robot",
"Your robot": "Twój robot", "Your robot": "Twój robot",
"#30": "Phrases in components/Dialogs/StoreToken.tsx", "#30": "Phrases in components/Dialogs/StoreToken.tsx",

View File

@ -305,7 +305,7 @@
"Generate a robot avatar first. Then create your own order.": "Generate a robot avatar first. Then create your own order.", "Generate a robot avatar first. Then create your own order.": "Generate a robot avatar first. Then create your own order.",
"You do not have a robot avatar": "Você não tem um avatar de robô", "You do not have a robot avatar": "Você não tem um avatar de robô",
"#29": "Phrases in components/Dialogs/Profile.tsx", "#29": "Phrases in components/Dialogs/Profile.tsx",
"Coordinators that know your robots": "Coordinators that know your robots", "Coordinators that know your robot:": "Coordinators that know your robot:",
"Your Robot": "Your Robot", "Your Robot": "Your Robot",
"Your robot": "Seu robô", "Your robot": "Seu robô",
"#30": "Phrases in components/Dialogs/StoreToken.tsx", "#30": "Phrases in components/Dialogs/StoreToken.tsx",

View File

@ -305,7 +305,7 @@
"Generate a robot avatar first. Then create your own order.": "Сначала создайте аватар робота. Затем создайте свой ордер.", "Generate a robot avatar first. Then create your own order.": "Сначала создайте аватар робота. Затем создайте свой ордер.",
"You do not have a robot avatar": "У Вас нет аватара робота", "You do not have a robot avatar": "У Вас нет аватара робота",
"#29": "Phrases in components/Dialogs/Profile.tsx", "#29": "Phrases in components/Dialogs/Profile.tsx",
"Coordinators that know your robots": "Coordinators that know your robots", "Coordinators that know your robot:": "Coordinators that know your robot:",
"Your Robot": "Ваш Robot", "Your Robot": "Ваш Robot",
"Your robot": "Ваш Робот", "Your robot": "Ваш Робот",
"#30": "Phrases in components/Dialogs/StoreToken.tsx", "#30": "Phrases in components/Dialogs/StoreToken.tsx",

View File

@ -305,7 +305,7 @@
"Generate a robot avatar first. Then create your own order.": "Generate a robot avatar first. Then create your own order.", "Generate a robot avatar first. Then create your own order.": "Generate a robot avatar first. Then create your own order.",
"You do not have a robot avatar": "Du har ingen robotavatar", "You do not have a robot avatar": "Du har ingen robotavatar",
"#29": "Phrases in components/Dialogs/Profile.tsx", "#29": "Phrases in components/Dialogs/Profile.tsx",
"Coordinators that know your robots": "Coordinators that know your robots", "Coordinators that know your robot:": "Coordinators that know your robot:",
"Your Robot": "Your Robot", "Your Robot": "Your Robot",
"Your robot": "Din robot", "Your robot": "Din robot",
"#30": "Phrases in components/Dialogs/StoreToken.tsx", "#30": "Phrases in components/Dialogs/StoreToken.tsx",

View File

@ -305,7 +305,7 @@
"Generate a robot avatar first. Then create your own order.": "Zalisha picha ya mwakilishi wa roboti kwanza. Kisha tengeneza amri yako mwenyewe.", "Generate a robot avatar first. Then create your own order.": "Zalisha picha ya mwakilishi wa roboti kwanza. Kisha tengeneza amri yako mwenyewe.",
"You do not have a robot avatar": "Huna picha ya mwakilishi wa roboti", "You do not have a robot avatar": "Huna picha ya mwakilishi wa roboti",
"#29": "Phrases in components/Dialogs/Profile.tsx", "#29": "Phrases in components/Dialogs/Profile.tsx",
"Coordinators that know your robots": "Coordinators that know your robots", "Coordinators that know your robot:": "Coordinators that know your robot:",
"Your Robot": "Roboti yako", "Your Robot": "Roboti yako",
"Your robot": "Roboti yako", "Your robot": "Roboti yako",
"#30": "Phrases in components/Dialogs/StoreToken.tsx", "#30": "Phrases in components/Dialogs/StoreToken.tsx",

View File

@ -305,7 +305,7 @@
"Generate a robot avatar first. Then create your own order.": "Generate a robot avatar first. Then create your own order.", "Generate a robot avatar first. Then create your own order.": "Generate a robot avatar first. Then create your own order.",
"You do not have a robot avatar": "คุณไม่มีโรบอท", "You do not have a robot avatar": "คุณไม่มีโรบอท",
"#29": "Phrases in components/Dialogs/Profile.tsx", "#29": "Phrases in components/Dialogs/Profile.tsx",
"Coordinators that know your robots": "Coordinators that know your robots", "Coordinators that know your robot:": "Coordinators that know your robot:",
"Your Robot": "Your Robot", "Your Robot": "Your Robot",
"Your robot": "โรบอทของคุณ", "Your robot": "โรบอทของคุณ",
"#30": "Phrases in components/Dialogs/StoreToken.tsx", "#30": "Phrases in components/Dialogs/StoreToken.tsx",

View File

@ -305,7 +305,7 @@
"Generate a robot avatar first. Then create your own order.": "请先生成一个机器人头像,然后创建你自己的订单。", "Generate a robot avatar first. Then create your own order.": "请先生成一个机器人头像,然后创建你自己的订单。",
"You do not have a robot avatar": "你没有机器人头像", "You do not have a robot avatar": "你没有机器人头像",
"#29": "Phrases in components/Dialogs/Profile.tsx", "#29": "Phrases in components/Dialogs/Profile.tsx",
"Coordinators that know your robots": "Coordinators that know your robots", "Coordinators that know your robot:": "Coordinators that know your robot:",
"Your Robot": "你的机器人", "Your Robot": "你的机器人",
"Your robot": "你的机器人", "Your robot": "你的机器人",
"#30": "Phrases in components/Dialogs/StoreToken.tsx", "#30": "Phrases in components/Dialogs/StoreToken.tsx",

View File

@ -305,7 +305,7 @@
"Generate a robot avatar first. Then create your own order.": "請先生成一個機器人頭像,然後創建你自己的訂單。", "Generate a robot avatar first. Then create your own order.": "請先生成一個機器人頭像,然後創建你自己的訂單。",
"You do not have a robot avatar": "你沒有機器人頭像", "You do not have a robot avatar": "你沒有機器人頭像",
"#29": "Phrases in components/Dialogs/Profile.tsx", "#29": "Phrases in components/Dialogs/Profile.tsx",
"Coordinators that know your robots": "Coordinators that know your robots", "Coordinators that know your robot:": "Coordinators that know your robot:",
"Your Robot": "你的機器人", "Your Robot": "你的機器人",
"Your robot": "你的機器人", "Your robot": "你的機器人",
"#30": "Phrases in components/Dialogs/StoreToken.tsx", "#30": "Phrases in components/Dialogs/StoreToken.tsx",