mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 09:01:17 -08:00
46 lines
1.7 KiB
TypeScript
46 lines
1.7 KiB
TypeScript
import type { ReactNode } from 'react';
|
|
import { useEffect } from 'react';
|
|
import { Box, Dialog, Text, config } from 'folds';
|
|
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
|
import { checkIndexedDBSupport } from '$utils/featureCheck';
|
|
import { SplashScreen } from '$components/splash-screen';
|
|
|
|
export function FeatureCheck({ children }: { children: ReactNode }) {
|
|
const [idbSupportState, checkIDBSupport] = useAsyncCallback(checkIndexedDBSupport);
|
|
|
|
useEffect(() => {
|
|
checkIDBSupport();
|
|
}, [checkIDBSupport]);
|
|
|
|
if (idbSupportState.status === AsyncStatus.Success && !idbSupportState.data) {
|
|
return (
|
|
<SplashScreen>
|
|
<Box grow="Yes" alignItems="Center" justifyContent="Center">
|
|
<Dialog>
|
|
<Box style={{ padding: config.space.S400 }} direction="Column" gap="400">
|
|
<Text>Missing Browser Feature</Text>
|
|
<Text size="T300" priority="400">
|
|
This app needs IndexedDB to save sessions, but your browser doesn't support it
|
|
or it's disabled. Please ensure IndexedDB is enabled, restart your browser,
|
|
check settings/extensions or privacy mode, free up disk space, or try updating/using
|
|
another browser.
|
|
</Text>
|
|
<Text size="T200">
|
|
<a
|
|
href="https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API"
|
|
rel="noreferrer noopener"
|
|
target="_blank"
|
|
>
|
|
What is IndexedDB?
|
|
</a>
|
|
</Text>
|
|
</Box>
|
|
</Dialog>
|
|
</Box>
|
|
</SplashScreen>
|
|
);
|
|
}
|
|
|
|
return children;
|
|
}
|