0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

fix(console): only check demo app existence on get-started page

This commit is contained in:
Charles Zhao 2022-06-07 18:48:34 +08:00
parent 2ba11215ed
commit e8ef4b650c
No known key found for this signature in database
GPG key ID: 4858774754C92DF2
3 changed files with 19 additions and 12 deletions

View file

@ -17,7 +17,7 @@ const GetStartedProgress = () => {
} = useUserPreferences();
const anchorRef = useRef<HTMLDivElement>(null);
const [showDropDown, setShowDropdown] = useState(false);
const { data, completedCount, totalCount } = useGetStartedMetadata();
const { data, completedCount, totalCount } = useGetStartedMetadata({ checkDemoAppExists: false });
if (hideGetStarted) {
return null;

View file

@ -23,17 +23,24 @@ type GetStartedMetadata = {
onClick: () => void;
};
const useGetStartedMetadata = () => {
const { settings, updateSettings } = useSettings();
const { data: demoApp, error } = useSWR<Application, RequestError>('/api/applications/demo_app', {
shouldRetryOnError: (error: unknown) => {
if (error instanceof RequestError) {
return error.status !== 404;
}
type Props = {
checkDemoAppExists: boolean;
};
return true;
},
});
const useGetStartedMetadata = ({ checkDemoAppExists }: Props) => {
const { settings, updateSettings } = useSettings();
const { data: demoApp, error } = useSWR<Application, RequestError>(
checkDemoAppExists && '/api/applications/demo_app',
{
shouldRetryOnError: (error: unknown) => {
if (error instanceof RequestError) {
return error.status !== 404;
}
return true;
},
}
);
const navigate = useNavigate();
const isLoadingDemoApp = !demoApp && !error;
const hideDemo = error?.status === 404;

View file

@ -16,7 +16,7 @@ import * as styles from './index.module.scss';
const GetStarted = () => {
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
const navigate = useNavigate();
const { data, isLoading } = useGetStartedMetadata();
const { data, isLoading } = useGetStartedMetadata({ checkDemoAppExists: true });
const { update } = useUserPreferences();
const [showConfirmModal, setShowConfirmModal] = useState(false);