11import type { ModData } from '@/components' ;
22import { buildModDataArray , downloadModsParallel , isManagedMod } from '@/components' ;
3- import { useSettings } from '@/hooks/useSettings' ;
43import { bindings } from '@/main' ;
54import useDownloadStore from '@/stores/downloadStore' ;
65import { getCachedOnboardingTips , loadOnboardingTips } from '@/utils/onboardingFunFacts' ;
76import { useToast } from '@/utils/toast' ;
87import { getMessageFromError , isLauncherError , useCommandSuspense } from '@onelauncher/common' ;
8+ import { useQueryClient } from '@tanstack/react-query' ;
99import { createFileRoute , useNavigate } from '@tanstack/react-router' ;
1010import { useCallback , useEffect , useMemo , useRef , useState } from 'react' ;
1111
@@ -45,12 +45,13 @@ function getErrorMessage(error: unknown): string {
4545
4646function RouteComponent ( ) {
4747 const navigate = useNavigate ( ) ;
48+ const queryClient = useQueryClient ( ) ;
4849 const { modsPerCluster, isFinishingOnboarding } = useDownloadStore ( ) ;
4950 const clearStore = useDownloadStore ( s => s . clear ) ;
5051 const markOnboardingFinishing = useDownloadStore ( s => s . markOnboardingFinishing ) ;
51- const { setSetting } = useSettings ( ) ;
5252 const toast = useToast ( ) ;
5353 const { data : clusters } = useCommandSuspense ( [ 'getClusters' ] , ( ) => bindings . core . getClusters ( ) ) ;
54+ const { data : settings } = useCommandSuspense ( [ 'readSettings' ] , bindings . core . readSettings ) ;
5455 const [ tips , setTips ] = useState < Array < string > > ( getCachedOnboardingTips ) ;
5556
5657 const clusterVersionById = useMemo ( ( ) => {
@@ -95,6 +96,10 @@ function RouteComponent() {
9596 } , [ isFinishingOnboarding , navigate ] ) ;
9697
9798 const mods = useMemo ( ( ) => buildModDataArray ( modsPerCluster ) , [ modsPerCluster ] ) ;
99+ const onboardingInstalledVersions = useMemo ( ( ) => {
100+ const versions = new Set ( clusters . map ( cluster => cluster . mc_version ) ) ;
101+ return [ ...versions ] . sort ( ) ;
102+ } , [ clusters ] ) ;
98103 const bundledManagedIdsByCluster = useMemo ( ( ) => {
99104 const map : Map < number , Set < string > > = new Map ( ) ;
100105
@@ -141,7 +146,18 @@ function RouteComponent() {
141146 finishTimerRef . current = window . setTimeout ( ( ) => {
142147 void ( async ( ) => {
143148 try {
144- await setSetting ( 'seen_onboarding' , true ) ;
149+ const storedSeenVersions = Array . isArray ( settings . seen_versions ) ? settings . seen_versions : [ ] ;
150+ const nextSeenVersions = [
151+ ...new Set ( [ ...onboardingInstalledVersions , ...storedSeenVersions ] ) ,
152+ ] . sort ( ) ;
153+ const nextSettings = {
154+ ...settings ,
155+ seen_onboarding : true ,
156+ seen_versions : nextSeenVersions ,
157+ } ;
158+
159+ await bindings . core . writeSettings ( nextSettings ) ;
160+ queryClient . setQueryData ( [ 'readSettings' ] , nextSettings ) ;
145161 }
146162 catch ( error ) {
147163 console . error ( '[onboarding/downloading] Failed to persist seen_onboarding before continue; navigating anyway.' , error ) ;
@@ -151,7 +167,15 @@ function RouteComponent() {
151167 clearStore ( ) ;
152168 } ) ( ) ;
153169 } , FADE_DURATION_MS ) ;
154- } , [ clearStore , isLeaving , markOnboardingFinishing , navigate , setSetting ] ) ;
170+ } , [
171+ clearStore ,
172+ isLeaving ,
173+ markOnboardingFinishing ,
174+ navigate ,
175+ onboardingInstalledVersions ,
176+ queryClient ,
177+ settings ,
178+ ] ) ;
155179
156180 useEffect ( ( ) => {
157181 return ( ) => {
0 commit comments