feat(core): prefetch onboarding video (#6736)

![CleanShot 2024-04-29 at 17.32.41@2x.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/g3jz87HxbjOJpXV3FPT7/21ebbc62-c4a2-496c-af05-600a2ded2a9d.png)
This commit is contained in:
EYHN
2024-04-29 12:13:16 +00:00
parent 5c861939a5
commit 1323a0fc5f

View File

@@ -67,6 +67,25 @@ const getPlayList = (t: Translate): Array<PlayListItem> => [
},
];
let prefetched = false;
function prefetchVideos() {
if (prefetched) return;
const videos = [
'/onboarding/ai-onboarding.general.1.mp4',
'/onboarding/ai-onboarding.general.2.mp4',
'/onboarding/ai-onboarding.general.3.mp4',
'/onboarding/ai-onboarding.general.4.mp4',
'/onboarding/ai-onboarding.general.5.mp4',
];
videos.forEach(video => {
const prefetchLink = document.createElement('link');
prefetchLink.href = video;
prefetchLink.rel = 'prefetch';
document.head.append(prefetchLink);
});
prefetched = true;
}
export const AIOnboardingGeneral = ({
onDismiss,
}: BaseAIOnboardingDialogProps) => {
@@ -116,6 +135,10 @@ export const AIOnboardingGeneral = ({
subscriptionService.subscription.revalidate();
}, [subscriptionService]);
useEffect(() => {
prefetchVideos();
}, []);
const videoRenderer = useCallback(
({ video }: PlayListItem, index: number) => (
<div className={styles.videoWrapper}>