@@ -6,10 +6,8 @@ package windowservice
66import (
77 "context"
88 "fmt"
9- "log"
109 "time"
1110
12- "github.com/wavetermdev/waveterm/pkg/eventbus"
1311 "github.com/wavetermdev/waveterm/pkg/panichandler"
1412 "github.com/wavetermdev/waveterm/pkg/tsgen/tsgenmeta"
1513 "github.com/wavetermdev/waveterm/pkg/waveobj"
@@ -82,63 +80,6 @@ func (ws *WindowService) SetWindowPosAndSize(ctx context.Context, windowId strin
8280 return waveobj .ContextGetUpdatesRtn (ctx ), nil
8381}
8482
85- func (svc * WindowService ) MoveBlockToNewWindow_Meta () tsgenmeta.MethodMeta {
86- return tsgenmeta.MethodMeta {
87- Desc : "move block to new window" ,
88- ArgNames : []string {"ctx" , "currentTabId" , "blockId" },
89- }
90- }
91-
92- func (svc * WindowService ) MoveBlockToNewWindow (ctx context.Context , currentTabId string , blockId string ) (waveobj.UpdatesRtnType , error ) {
93- log .Printf ("MoveBlockToNewWindow(%s, %s)" , currentTabId , blockId )
94- ctx = waveobj .ContextWithUpdates (ctx )
95- tab , err := wstore .DBMustGet [* waveobj.Tab ](ctx , currentTabId )
96- if err != nil {
97- return nil , fmt .Errorf ("error getting tab: %w" , err )
98- }
99- log .Printf ("tab.BlockIds[%s]: %v" , tab .OID , tab .BlockIds )
100- var foundBlock bool
101- for _ , tabBlockId := range tab .BlockIds {
102- if tabBlockId == blockId {
103- foundBlock = true
104- break
105- }
106- }
107- if ! foundBlock {
108- return nil , fmt .Errorf ("block not found in current tab" )
109- }
110- newWindow , err := wcore .CreateWindow (ctx , nil , "" )
111- if err != nil {
112- return nil , fmt .Errorf ("error creating window: %w" , err )
113- }
114- ws , err := wcore .GetWorkspace (ctx , newWindow .WorkspaceId )
115- if err != nil {
116- return nil , fmt .Errorf ("error getting workspace: %w" , err )
117- }
118- err = wstore .MoveBlockToTab (ctx , currentTabId , ws .ActiveTabId , blockId )
119- if err != nil {
120- return nil , fmt .Errorf ("error moving block to tab: %w" , err )
121- }
122- eventbus .SendEventToElectron (eventbus.WSEventType {
123- EventType : eventbus .WSEvent_ElectronNewWindow ,
124- Data : newWindow .OID ,
125- })
126- windowCreated := eventbus .BusyWaitForWindowId (newWindow .OID , 2 * time .Second )
127- if ! windowCreated {
128- return nil , fmt .Errorf ("new window not created" )
129- }
130- wcore .QueueLayoutActionForTab (ctx , currentTabId , waveobj.LayoutActionData {
131- ActionType : wcore .LayoutActionDataType_Remove ,
132- BlockId : blockId ,
133- })
134- wcore .QueueLayoutActionForTab (ctx , ws .ActiveTabId , waveobj.LayoutActionData {
135- ActionType : wcore .LayoutActionDataType_Insert ,
136- BlockId : blockId ,
137- Focused : true ,
138- })
139- return waveobj .ContextGetUpdatesRtn (ctx ), nil
140- }
141-
14283func (svc * WindowService ) SwitchWorkspace_Meta () tsgenmeta.MethodMeta {
14384 return tsgenmeta.MethodMeta {
14485 ArgNames : []string {"ctx" , "windowId" , "workspaceId" },
0 commit comments