chore: fix qr login connection check

This commit is contained in:
AP 2020-02-24 21:54:52 +01:00
parent eef57d6afc
commit e3f3778067
6 changed files with 30 additions and 15 deletions

View file

@ -1,6 +1,6 @@
{
"name": "app",
"version": "0.1.6.1",
"version": "0.1.6.2",
"private": true,
"dependencies": {
"@apollo/react-hooks": "^3.1.3",

View file

@ -127,8 +127,9 @@ export const QRLogin = ({ handleSet }: QRLoginProps) => {
return (
<QRTextWrapper>
<SubTitle>
Make sure you have given ThunderHub the correct
permissions to use the camara.
Make sure you have a camara available and that you
have given ThunderHub the correct permissions to use
it.
</SubTitle>
</QRTextWrapper>
);

View file

@ -1,3 +1,4 @@
import { useEffect } from 'react';
import {
useConnectionState,
useConnectionDispatch,
@ -18,16 +19,19 @@ export const ConnectionCheck = () => {
cert,
);
useQuery(GET_CAN_CONNECT, {
const { data, loading } = useQuery(GET_CAN_CONNECT, {
variables: { auth },
skip: connected || !loggedIn,
onError: () => {
dispatch({ type: 'error' });
},
onCompleted: () => {
dispatch({ type: 'connected' });
},
});
useEffect(() => {
if (!loading && data && data.getNodeInfo) {
dispatch({ type: 'connected' });
}
}, [data, loading]);
return null;
};

View file

@ -20,7 +20,6 @@ const stateReducer = (state: State, action: ActionType) => {
case 'connected':
return { connected: true, loading: false, error: false };
case 'loading':
return { connected: false, loading: true, error: false };
case 'disconnected':
return { connected: false, loading: true, error: false };
default:

View file

@ -57,6 +57,12 @@ export const AccountSettings = () => {
>
BTCPayServer Info
</SingleButton>
<SingleButton
selected={isType === 'qrcode'}
onClick={() => setIsType('qrcode')}
>
QR Code
</SingleButton>
</MultiButton>
</SingleLine>
);
@ -71,14 +77,21 @@ export const AccountSettings = () => {
{getStorageSaved().map((entry, index) => {
return (
<SingleButton
key={index}
selected={
name.localeCompare(entry.name) === 0
}
onClick={() => {
dispatch({ type: 'disconnected' });
dispatchState({ type: 'disconnected' });
changeAccount(entry.index);
push('/');
if (
name.localeCompare(entry.name) !== 0
) {
dispatch({ type: 'disconnected' });
dispatchState({
type: 'disconnected',
});
changeAccount(entry.index);
push('/');
}
}}
>
{entry.name}

View file

@ -35,9 +35,7 @@ export const CurrentSettings = () => {
return (
<>
<Sub4Title>{title}</Sub4Title>
<CurrentField rows={rows ?? 3} readOnly={true}>
{field}
</CurrentField>
<CurrentField rows={rows ?? 3} readOnly={true} value={field} />
</>
);
};