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
open={open.profile}
baseUrl={hostUrl}
onClose={() => {
setOpen({ ...open, profile: false });
}}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -74,14 +74,6 @@ export interface Origins {
i2p: Origin | undefined;
}
export interface getEndpointProps {
coordinator: Coordinator;
network: 'mainnet' | 'testnet';
origin: Origin;
selfHosted: boolean;
hostUrl: string;
}
export class Coordinator {
constructor(value: any) {
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.",
"You do not have a robot avatar": "No tens un avatar robot",
"#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",
"#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": "Nemáš robota a avatar",
"#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": "Tvůj robot",
"#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": "Du hast keinen Roboter-Avatar",
"#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": "Dein Roboter",
"#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",
"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",

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.",
"You do not have a robot avatar": "No tienes un avatar robot",
"#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": "Tu Robot",
"#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": "Ez daukazu robot avatarrik",
"#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": "Zure robota",
"#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.",
"You do not have a robot avatar": "Vous n'avez pas d'avatar robot",
"#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",
"#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.",
"You do not have a robot avatar": "Non hai un avatar robot",
"#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",
"#30": "Phrases in components/Dialogs/StoreToken.tsx",

View File

@ -305,7 +305,7 @@
"Generate a robot avatar first. Then create your own order.": "最初にロボットアバターを生成してください。次に自分のオーダーを作成してください。",
"You do not have a robot avatar": "ロボットのアバターがありません",
"#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": "あなたのロボット",
"#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",
"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": "Twój robot",
"#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": "Você não tem um avatar de robô",
"#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": "Seu robô",
"#30": "Phrases in components/Dialogs/StoreToken.tsx",

View File

@ -305,7 +305,7 @@
"Generate a robot avatar first. Then create your own order.": "Сначала создайте аватар робота. Затем создайте свой ордер.",
"You do not have a robot avatar": "У Вас нет аватара робота",
"#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": "Ваш Робот",
"#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": "Du har ingen robotavatar",
"#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": "Din robot",
"#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.",
"You do not have a robot avatar": "Huna picha ya mwakilishi wa roboti",
"#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",
"#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": "คุณไม่มีโรบอท",
"#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": "โรบอทของคุณ",
"#30": "Phrases in components/Dialogs/StoreToken.tsx",

View File

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

View File

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