Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only create starter workspace on first launch #1599

Merged
merged 1 commit into from
Dec 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions pkg/wcore/wcore.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func EnsureInitialData() error {
ctx, cancelFn := context.WithTimeout(context.Background(), 2*time.Second)
defer cancelFn()
client, err := wstore.DBGetSingleton[*waveobj.Client](ctx)
firstLaunch := false
if err == wstore.ErrNotFound {
client, err = CreateClient(ctx)
if err != nil {
Expand All @@ -34,6 +35,7 @@ func EnsureInitialData() error {
if migrateErr != nil {
log.Printf("error migrating old history: %v\n", migrateErr)
}
firstLaunch = true
}
if client.TempOID == "" {
log.Println("client.TempOID is empty")
Expand All @@ -53,12 +55,16 @@ func EnsureInitialData() error {
log.Println("client has windows")
return nil
}
log.Println("client has no windows, creating starter workspace")
starterWs, err := CreateWorkspace(ctx, "Starter workspace", "custom@wave-logo-solid", "#58C142", false, true)
if err != nil {
return fmt.Errorf("error creating starter workspace: %w", err)
wsId := ""
if firstLaunch {
log.Println("client has no windows and first launch, creating starter workspace")
starterWs, err := CreateWorkspace(ctx, "Starter workspace", "custom@wave-logo-solid", "#58C142", false, true)
if err != nil {
return fmt.Errorf("error creating starter workspace: %w", err)
}
wsId = starterWs.OID
}
_, err = CreateWindow(ctx, nil, starterWs.OID)
_, err = CreateWindow(ctx, nil, wsId)
if err != nil {
return fmt.Errorf("error creating window: %w", err)
}
Expand Down
Loading