mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-21 16:38:23 +01:00
fix broken windows (with no tabs) (#867)
This commit is contained in:
parent
68dfc4ab90
commit
e567434b03
@ -137,6 +137,26 @@ func CreateWindow(ctx context.Context, winSize *waveobj.WinSize) (*waveobj.Windo
|
||||
return wstore.DBMustGet[*waveobj.Window](ctx, windowId)
|
||||
}
|
||||
|
||||
func checkAndFixWindow(ctx context.Context, windowId string) {
|
||||
window, err := wstore.DBMustGet[*waveobj.Window](ctx, windowId)
|
||||
if err != nil {
|
||||
log.Printf("error getting window %q (in checkAndFixWindow): %v\n", windowId, err)
|
||||
return
|
||||
}
|
||||
workspace, err := wstore.DBMustGet[*waveobj.Workspace](ctx, window.WorkspaceId)
|
||||
if err != nil {
|
||||
log.Printf("error getting workspace %q (in checkAndFixWindow): %v\n", window.WorkspaceId, err)
|
||||
return
|
||||
}
|
||||
if len(workspace.TabIds) == 0 {
|
||||
log.Printf("fixing workspace with no tabs %q (in checkAndFixWindow)\n", workspace.OID)
|
||||
_, err = CreateTab(ctx, windowId, "T1", true)
|
||||
if err != nil {
|
||||
log.Printf("error creating tab (in checkAndFixWindow): %v\n", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// returns (new-window, first-time, error)
|
||||
func EnsureInitialData() (*waveobj.Window, bool, error) {
|
||||
// does not need to run in a transaction since it is called on startup
|
||||
@ -152,6 +172,9 @@ func EnsureInitialData() (*waveobj.Window, bool, error) {
|
||||
firstRun = true
|
||||
}
|
||||
log.Printf("clientid: %s\n", client.OID)
|
||||
if len(client.WindowIds) == 1 {
|
||||
checkAndFixWindow(ctx, client.WindowIds[0])
|
||||
}
|
||||
if len(client.WindowIds) > 0 {
|
||||
return nil, false, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user