Skip to content

Commit

Permalink
feat(core): prefetch onboarding video
Browse files Browse the repository at this point in the history
  • Loading branch information
EYHN committed Apr 29, 2024
1 parent 6202ba5 commit c6bc960
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.body.append(prefetchLink);
});
prefetched = true;
}

export const AIOnboardingGeneral = ({
onDismiss,
}: BaseAIOnboardingDialogProps) => {
Expand Down Expand Up @@ -116,6 +135,10 @@ export const AIOnboardingGeneral = ({
subscriptionService.subscription.revalidate();
}, [subscriptionService]);

useEffect(() => {
prefetchVideos();
}, []);

const videoRenderer = useCallback(
({ video }: PlayListItem, index: number) => (
<div className={styles.videoWrapper}>
Expand Down

0 comments on commit c6bc960

Please sign in to comment.