Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ const ErrorComponent = ({ resetError }: FallbackComponentProps) => {
};

const App = () => {
const { accountConfig } = useAccountConfig({ refresh: false });
const { accountConfig } = useAccountConfig({
refresh: false,
listenAppState: true
});
const navigate = useNavigate();

useDeepLink();
Expand Down
7 changes: 4 additions & 3 deletions src/hooks/useAccountConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ const oldAppRootUrl = "https://checkout.swiss-bitcoin-pay.ch";

type UseAccountConfigParams = {
refresh?: boolean;
listenAppState?: boolean;
};

export const useAccountConfig = (props?: UseAccountConfigParams) => {
const { refresh = true } = props || {};
const { refresh = true, listenAppState = false } = props || {};
const navigate = useNavigate();
const { accountConfig, setUserType, setAccountConfig } =
useContext(SBPContext);
Expand Down Expand Up @@ -69,7 +70,7 @@ export const useAccountConfig = (props?: UseAccountConfigParams) => {
const appState = useRef(AppState.currentState);

useEffect(() => {
if (accountConfig?.apiKey && AppState.isAvailable) {
if (listenAppState && accountConfig?.apiKey && AppState.isAvailable) {
const subscription = AppState.addEventListener(
"change",
(nextAppState) => {
Expand All @@ -86,7 +87,7 @@ export const useAccountConfig = (props?: UseAccountConfigParams) => {

return () => subscription.remove();
}
}, [accountConfig?.apiKey]);
}, [listenAppState, accountConfig?.apiKey]);

const onScan = useCallback(
async (scannedValue: string) => {
Expand Down
Loading