Skip to content

Commit

Permalink
Added existed user logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mazhutoanton committed Sep 7, 2023
1 parent b315563 commit 56dce56
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/sdk/src/GameSdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ export class GamesSDK {
await onStart?.();
modal.close();
},
navigateToNextScreen: () => {
modal.close();
this.showLeaderboard({ onPlayAgain: () => window.location.reload() });
},
});

open();
Expand Down
13 changes: 11 additions & 2 deletions packages/ui/src/widgets/Preloader/Preloader.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import styled from '@emotion/styled';
import { useMemo } from 'react';

import { Button, ProgressiveImg, Stack, Typography, Steps } from '../../components';
import { useAsyncCallback, useConfigContext, useGameInfo, useMediaQuery } from '../../hooks';
import { useAsyncCallback, useConfigContext, useGameInfo, useMediaQuery, useWalletContext } from '../../hooks';

const ImageBlock = styled.div(
{
Expand Down Expand Up @@ -57,13 +58,21 @@ const StartButton = styled(Button)(
export type PreloaderProps = {
ready?: boolean;
onStartClick?: () => Promise<void> | void;
navigateToNextScreen?: () => void;
};

export const Preloader = ({ ready = false, onStartClick }: PreloaderProps) => {
export const Preloader = ({ ready = false, onStartClick, navigateToNextScreen }: PreloaderProps) => {
const isLandscape = useMediaQuery('(max-height: 440px)');
const [handleStartClick, isBusy] = useAsyncCallback(onStartClick);
const { loading, preloader } = useGameInfo();
const { sdkUrl: cdnUrl } = useConfigContext();
const { isReady, address } = useWalletContext();

const walletStatus = useMemo(() => (isReady ? 'READY' : 'NOT_READY'), [isReady]);

if (walletStatus === 'READY' && address) {
navigateToNextScreen?.();
}

return (
<Widget spacing={isLandscape ? 2 : 4} align="center">
Expand Down

0 comments on commit 56dce56

Please sign in to comment.