Skip to content

Commit

Permalink
Merge pull request #570 from Kodylow/gateway-context
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodylow authored Nov 15, 2024
2 parents 1ee9f74 + ea96064 commit da3158b
Show file tree
Hide file tree
Showing 52 changed files with 1,015 additions and 1,000 deletions.
2 changes: 1 addition & 1 deletion apps/router/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Flex, Text } from '@chakra-ui/react';
import { Logo } from './Logo';
import { ServiceMenu } from './ServiceMenu';
import { useActiveService } from '../hooks';
import { useAppContext } from '../context/hooks';
import { useAppContext } from '../hooks';

export const Header = React.memo(function Header() {
const { guardians, gateways } = useAppContext();
Expand Down
19 changes: 18 additions & 1 deletion apps/router/src/context/gateway/GatewayContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import React, {
useMemo,
useReducer,
} from 'react';
import { useGatewayConfig } from '../hooks';
import { useGatewayConfig } from '../../hooks';
import { GatewayApi } from '../../api/GatewayApi';
import {
GATEWAY_APP_ACTION_TYPE,
GatewayAppAction,
GatewayAppState,
GatewayStatus,
WalletModalAction,
WalletModalType,
} from '../../types/gateway';
import { useLocation } from 'react-router-dom';

Expand All @@ -29,6 +31,15 @@ const initialState: GatewayAppState = {
balances: null,
gatewayInfo: null,
unit: 'msats',
showConnectFed: false,
walletModalState: {
isOpen: false,
action: WalletModalAction.Receive,
type: WalletModalType.Onchain,
selectedFederation: null,
showSelector: true,
},
activeTab: 0,
};

const reducer = (
Expand All @@ -48,6 +59,12 @@ const reducer = (
return { ...state, gatewayInfo: action.payload };
case GATEWAY_APP_ACTION_TYPE.SET_UNIT:
return { ...state, unit: action.payload };
case GATEWAY_APP_ACTION_TYPE.SET_SHOW_CONNECT_FED:
return { ...state, showConnectFed: action.payload };
case GATEWAY_APP_ACTION_TYPE.SET_WALLET_MODAL_STATE:
return { ...state, walletModalState: { ...state.walletModalState, ...action.payload } };
case GATEWAY_APP_ACTION_TYPE.SET_ACTIVE_TAB:
return { ...state, activeTab: action.payload };
default:
return state;
}
Expand Down
3 changes: 1 addition & 2 deletions apps/router/src/context/guardian/AdminContext.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { createContext, ReactNode } from 'react';
// import { AdminApiInterface } from '../guardian-ui/GuardianApi';
import { useGuardianStatus } from '../hooks';
import { useGuardianStatus } from '../../hooks';
import { GuardianStatus } from '../../types/guardian';

// export interface AdminContextValue {}
Expand Down
2 changes: 1 addition & 1 deletion apps/router/src/context/guardian/GuardianContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
GuardianAppState,
GuardianStatus,
} from '../../types/guardian';
import { useGuardianConfig } from '../hooks';
import { useGuardianConfig } from '../../hooks';
import { useLocation } from 'react-router-dom';

export interface GuardianContextValue {
Expand Down
6 changes: 3 additions & 3 deletions apps/router/src/context/guardian/SetupContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { randomNames } from '../../guardian-ui/setup/randomNames';
import {
FollowerConfigs,
HostConfigs,
useGuardianContext,
useGuardianApi,
useHandleBackgroundGuardianSetupActions,
useHandleSetupServerStatus,
useUpdateLocalStorageOnSetupStateChange,
} from '../hooks';
} from '../../hooks';

export const LOCAL_STORAGE_SETUP_KEY = 'setup-guardian-ui-state';

Expand Down Expand Up @@ -123,7 +123,7 @@ export const SetupContextProvider: React.FC<SetupContextProviderProps> = ({
initServerStatus,
children,
}: SetupContextProviderProps) => {
const { api } = useGuardianContext();
const api = useGuardianApi();
const [state, dispatch] = useReducer(reducer, {
...initialState,
password: api.getPassword() || initialState.password,
Expand Down
Loading

0 comments on commit da3158b

Please sign in to comment.