@@ -20,7 +20,7 @@ import (
2020// orchestrating the wave object store, the wave pubsub system, and the wave rpc system
2121
2222// Ensures that the initial data is present in the store, creates an initial window if needed
23- func EnsureInitialData () error {
23+ func EnsureInitialData () ( bool , error ) {
2424 // does not need to run in a transaction since it is called on startup
2525 ctx , cancelFn := context .WithTimeout (context .Background (), 2 * time .Second )
2626 defer cancelFn ()
@@ -29,11 +29,7 @@ func EnsureInitialData() error {
2929 if err == wstore .ErrNotFound {
3030 client , err = CreateClient (ctx )
3131 if err != nil {
32- return fmt .Errorf ("error creating client: %w" , err )
33- }
34- migrateErr := wstore .TryMigrateOldHistory ()
35- if migrateErr != nil {
36- log .Printf ("error migrating old history: %v\n " , migrateErr )
32+ return false , fmt .Errorf ("error creating client: %w" , err )
3733 }
3834 firstLaunch = true
3935 }
@@ -42,33 +38,33 @@ func EnsureInitialData() error {
4238 client .TempOID = uuid .NewString ()
4339 err = wstore .DBUpdate (ctx , client )
4440 if err != nil {
45- return fmt .Errorf ("error updating client: %w" , err )
41+ return firstLaunch , fmt .Errorf ("error updating client: %w" , err )
4642 }
4743 }
4844 log .Printf ("clientid: %s\n " , client .OID )
4945 if len (client .WindowIds ) == 1 {
5046 log .Println ("client has one window" )
5147 CheckAndFixWindow (ctx , client .WindowIds [0 ])
52- return nil
48+ return firstLaunch , nil
5349 }
5450 if len (client .WindowIds ) > 0 {
5551 log .Println ("client has windows" )
56- return nil
52+ return firstLaunch , nil
5753 }
5854 wsId := ""
5955 if firstLaunch {
6056 log .Println ("client has no windows and first launch, creating starter workspace" )
6157 starterWs , err := CreateWorkspace (ctx , "Starter workspace" , "custom@wave-logo-solid" , "#58C142" , false , true )
6258 if err != nil {
63- return fmt .Errorf ("error creating starter workspace: %w" , err )
59+ return firstLaunch , fmt .Errorf ("error creating starter workspace: %w" , err )
6460 }
6561 wsId = starterWs .OID
6662 }
6763 _ , err = CreateWindow (ctx , nil , wsId )
6864 if err != nil {
69- return fmt .Errorf ("error creating window: %w" , err )
65+ return firstLaunch , fmt .Errorf ("error creating window: %w" , err )
7066 }
71- return nil
67+ return firstLaunch , nil
7268}
7369
7470func CreateClient (ctx context.Context ) (* waveobj.Client , error ) {
0 commit comments