MCPcopy
hub / github.com/wavetermdev/waveterm / QueueLayoutAction

Function QueueLayoutAction

pkg/wcore/layout.go:82–105  ·  view source on GitHub ↗
(ctx context.Context, layoutStateId string, actions ...waveobj.LayoutActionData)

Source from the content-addressed store, hash-verified

80}
81
82func QueueLayoutAction(ctx context.Context, layoutStateId string, actions ...waveobj.LayoutActionData) error {
83 layoutStateObj, err := wstore.DBGet[*waveobj.LayoutState](ctx, layoutStateId)
84 if err != nil {
85 return fmt.Errorf("unable to get layout state for given id %s: %w", layoutStateId, err)
86 }
87
88 for i := range actions {
89 if actions[i].ActionId == "" {
90 actions[i].ActionId = uuid.New().String()
91 }
92 }
93
94 if layoutStateObj.PendingBackendActions == nil {
95 layoutStateObj.PendingBackendActions = &actions
96 } else {
97 *layoutStateObj.PendingBackendActions = append(*layoutStateObj.PendingBackendActions, actions...)
98 }
99
100 err = wstore.DBUpdate(ctx, layoutStateObj)
101 if err != nil {
102 return fmt.Errorf("unable to update layout state with new actions: %w", err)
103 }
104 return nil
105}
106
107func QueueLayoutActionForTab(ctx context.Context, tabId string, actions ...waveobj.LayoutActionData) error {
108 layoutStateId, err := GetLayoutIdForTab(ctx, tabId)

Callers 1

QueueLayoutActionForTabFunction · 0.85

Calls 3

DBGetFunction · 0.92
DBUpdateFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected