mirror of
https://github.com/RoboSats/robosats.git
synced 2025-07-17 16:23:13 +00:00
Better code
This commit is contained in:
@ -4,7 +4,6 @@ import FederationTable from '../../components/FederationTable';
|
||||
import { t } from 'i18next';
|
||||
import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
|
||||
import { GarageContext, type UseGarageStoreType } from '../../contexts/GarageContext';
|
||||
import { Garage } from '../../models';
|
||||
import { Origin, Origins } from '../../models/Coordinator.model';
|
||||
import { AppContext, UseAppStoreType } from '../../contexts/AppContext';
|
||||
|
||||
@ -20,11 +19,7 @@ const Coordinators = (): React.JSX.Element => {
|
||||
// Regular expression to match a valid .onion URL
|
||||
const onionUrlPattern = /^((http|https):\/\/)?[a-zA-Z2-7]{16,56}\.onion$\/?/;
|
||||
|
||||
const addNewCoordinator: (alias: string, garage: Garage, url: string) => void = (
|
||||
alias,
|
||||
garage,
|
||||
url,
|
||||
) => {
|
||||
const addNewCoordinator: (alias: string, url: string) => void = (alias, url) => {
|
||||
if (!federation.getCoordinator(alias)) {
|
||||
const attributes: object = {
|
||||
longAlias: alias,
|
||||
@ -57,7 +52,7 @@ const Coordinators = (): React.JSX.Element => {
|
||||
if (!/^((http|https):\/\/)/.test(fullNewUrl)) {
|
||||
fullNewUrl = `http://${newUrl}`;
|
||||
}
|
||||
addNewCoordinator(newAlias, garage, fullNewUrl);
|
||||
addNewCoordinator(newAlias, fullNewUrl);
|
||||
garage.syncCoordinator(federation, newAlias);
|
||||
setNewAlias('');
|
||||
setNewUrl('');
|
||||
|
@ -69,7 +69,7 @@ const DepthChart: React.FC<DepthChartProps> = ({
|
||||
if (Object.values(federation.book).length > 0) {
|
||||
const enriched = Object.values(federation.book).map((order) => {
|
||||
if (order?.currency) {
|
||||
const limits = federation.getCoordinators()[0]?.limits;
|
||||
const limits = federation.getLimits();
|
||||
|
||||
const originalPrice =
|
||||
(limits[order.currency]?.price ?? 0) * (1 + parseFloat(order.premium) / 100);
|
||||
|
@ -216,15 +216,11 @@ export class Federation {
|
||||
this.triggerHook('onFederationUpdate');
|
||||
};
|
||||
|
||||
getLimits = (shortAlias: string): LimitList => {
|
||||
console.log('shortAlias', shortAlias);
|
||||
let limits = this.coordinators[shortAlias]?.limits || {};
|
||||
|
||||
console.log('limits pre', Object.keys(limits).length);
|
||||
getLimits = (shortAlias?: string): LimitList => {
|
||||
let limits = shortAlias ? this.coordinators[shortAlias]?.limits || {} : {};
|
||||
if (Object.keys(limits).length === 0) {
|
||||
limits = this.getCoordinators()[0]?.limits;
|
||||
}
|
||||
console.log('limits', Object.keys(limits).length);
|
||||
return limits;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user