Skip to content

Commit

Permalink
Merge pull request #1495 from RoboSats/use-nostr-in-book-page
Browse files Browse the repository at this point in the history
Use nostr in book page
  • Loading branch information
KoalaSat authored Oct 18, 2024
2 parents 87cb76b + 1695745 commit 7bf1d51
Show file tree
Hide file tree
Showing 50 changed files with 10,631 additions and 290 deletions.
134 changes: 133 additions & 1 deletion frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@babel/preset-typescript": "^7.22.5",
"@babel/runtime": "^7.22.6",
"@types/jest": "^29.5.3",
"@types/latlon-geohash": "^2.0.3",
"@types/leaflet": "^1.9.7",
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
Expand Down Expand Up @@ -71,8 +72,10 @@
"i18next-http-backend": "^2.5.0",
"install": "^0.13.0",
"js-sha256": "^0.11.0",
"latlon-geohash": "^2.0.0",
"leaflet": "^1.9.4",
"light-bolt11-decoder": "^3.1.1",
"nostr-tools": "^2.7.2",
"npm": "^10.8.1",
"openpgp": "^5.11.0",
"react": "^18.2.0",
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/basic/MakerPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext, useMemo, useState } from 'react';
import React, { useContext, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import { Grid, Paper, Collapse, Typography } from '@mui/material';
Expand All @@ -13,7 +13,7 @@ import { FederationContext, type UseFederationStoreType } from '../../contexts/F
import { GarageContext, type UseGarageStoreType } from '../../contexts/GarageContext';

const MakerPage = (): JSX.Element => {
const { fav, windowSize, navbarHeight } = useContext<UseAppStoreType>(AppContext);
const { fav, windowSize, navbarHeight, page } = useContext<UseAppStoreType>(AppContext);
const { federation } = useContext<UseFederationStoreType>(FederationContext);
const { garage, maker } = useContext<UseGarageStoreType>(GarageContext);
const { t } = useTranslation();
Expand All @@ -25,7 +25,7 @@ const MakerPage = (): JSX.Element => {

const matches = useMemo(() => {
return filterOrders({
orders: federation.book,
federation,
baseFilter: {
currency: fav.currency === 0 ? 1 : fav.currency,
type: fav.type,
Expand Down
10 changes: 4 additions & 6 deletions frontend/src/basic/RobotPage/RobotProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
import { genBase62Token } from '../../utils';
import { LoadingButton } from '@mui/lab';
import { GarageContext, type UseGarageStoreType } from '../../contexts/GarageContext';
import { FederationContext, UseFederationStoreType } from '../../contexts/FederationContext';

interface RobotProfileProps {
robot: Robot;
Expand All @@ -45,6 +46,7 @@ const RobotProfile = ({
}: RobotProfileProps): JSX.Element => {
const { windowSize, client } = useContext<UseAppStoreType>(AppContext);
const { garage, slotUpdatedAt } = useContext<UseGarageStoreType>(GarageContext);
const { federation } = useContext<UseFederationStoreType>(FederationContext);

const { t } = useTranslation();
const theme = useTheme();
Expand Down Expand Up @@ -75,10 +77,6 @@ const RobotProfile = ({
const slot = garage.getSlot();
const robot = slot?.getRobot();

const loadingCoordinators = Object.values(slot?.robots ?? {}).filter(
(robot) => robot.loading,
).length;

return (
<Grid container direction='column' alignItems='center' spacing={1} padding={1} paddingTop={2}>
<Grid
Expand Down Expand Up @@ -154,7 +152,7 @@ const RobotProfile = ({
)}
</Grid>

{loadingCoordinators > 0 && !slot?.activeOrder?.id ? (
{federation.loading && !slot?.activeOrder?.id ? (
<Grid>
<b>{t('Looking for orders!')}</b>
<LinearProgress />
Expand Down Expand Up @@ -208,7 +206,7 @@ const RobotProfile = ({
</Grid>
) : null}

{!slot?.activeOrder && !slot?.lastOrder && loadingCoordinators === 0 ? (
{!slot?.activeOrder && !slot?.lastOrder && !federation.loading ? (
<Grid item>{t('No existing orders found')}</Grid>
) : null}

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/basic/RobotPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { GarageContext, type UseGarageStoreType } from '../../contexts/GarageCon
const RobotPage = (): JSX.Element => {
const { torStatus, windowSize, settings, page, client } = useContext<UseAppStoreType>(AppContext);
const { garage } = useContext<UseGarageStoreType>(GarageContext);
const { federation, sortedCoordinators } = useContext<UseFederationStoreType>(FederationContext);
const { federation } = useContext<UseFederationStoreType>(FederationContext);
const { t } = useTranslation();
const params = useParams();
const urlToken = settings.selfhostedClient ? params.token : null;
Expand Down Expand Up @@ -64,7 +64,7 @@ const RobotPage = (): JSX.Element => {
setInputToken(token);
genKey(token)
.then((key) => {
garage.createRobot(token, sortedCoordinators, {
garage.createRobot(token, Object.keys(federation.coordinators), {
token,
pubKey: key.publicKeyArmored,
encPrivKey: key.encryptedPrivateKeyArmored,
Expand Down
Loading

0 comments on commit 7bf1d51

Please sign in to comment.