multi-window support (#62)

This commit is contained in:
Mike Sawka
2024-06-19 19:10:53 -07:00
committed by GitHub
parent 5c6cfbc112
commit fb668fd4e5
14 changed files with 423 additions and 126 deletions
@@ -8,6 +8,7 @@ import (
"fmt"
"time"
"github.com/wavetermdev/thenextwave/pkg/util/utilfn"
"github.com/wavetermdev/thenextwave/pkg/wstore"
)
@@ -54,3 +55,21 @@ func (cs *ClientService) GetWindow(windowId string) (*wstore.Window, error) {
}
return window, nil
}
func (cs *ClientService) MakeWindow(ctx context.Context) (*wstore.Window, error) {
return wstore.CreateWindow(ctx)
}
// moves the window to the front of the windowId stack
func (cs *ClientService) FocusWindow(ctx context.Context, windowId string) error {
client, err := cs.GetClientData()
if err != nil {
return err
}
winIdx := utilfn.SliceIdx(client.WindowIds, windowId)
if winIdx == -1 {
return nil
}
client.WindowIds = utilfn.MoveSliceIdxToFront(client.WindowIds, winIdx)
return wstore.DBUpdate(ctx, client)
}