fix wsh view et al, send updates via ws

This commit is contained in:
sawka 2024-08-29 18:23:12 -07:00
parent 6e704f74e3
commit 2d883da8f0
2 changed files with 22 additions and 3 deletions

View File

@ -135,3 +135,19 @@ func ContextGetUpdatesRtn(ctx context.Context) UpdatesRtnType {
}
return rtn
}
func ContextPrintUpdates(ctx context.Context) {
updatesVal := ctx.Value(waveObjUpdateKey)
if updatesVal == nil {
log.Print("no updates\n")
return
}
updates := updatesVal.(*contextUpdatesType)
log.Printf("updates len:%d\n", len(updates.UpdatesStack))
for idx, update := range updates.UpdatesStack {
log.Printf(" update[%d]:\n", idx)
for k, v := range update {
log.Printf(" %s:%s %s\n", k.OType, k.OID, v.UpdateType)
}
}
}

View File

@ -269,8 +269,6 @@ func (ws *WshServer) CreateBlockCommand(ctx context.Context, data wshrpc.Command
return nil, fmt.Errorf("error creating block: %w", err)
}
blockRef := &waveobj.ORef{OType: waveobj.OType_Block, OID: blockData.OID}
updates := waveobj.ContextGetUpdatesRtn(ctx)
sendWStoreUpdatesToEventBus(updates)
windowId, err := wstore.DBFindWindowForTabId(ctx, tabId)
if err != nil {
return nil, fmt.Errorf("error finding window for tab: %w", err)
@ -278,12 +276,17 @@ func (ws *WshServer) CreateBlockCommand(ctx context.Context, data wshrpc.Command
if windowId == "" {
return nil, fmt.Errorf("no window found for tab")
}
wlayout.QueueLayoutActionForTab(ctx, tabId, waveobj.LayoutActionData{
err = wlayout.QueueLayoutActionForTab(ctx, tabId, waveobj.LayoutActionData{
ActionType: wlayout.LayoutActionDataType_Insert,
BlockId: blockRef.OID,
Magnified: data.Magnified,
Focused: true,
})
if err != nil {
return nil, fmt.Errorf("error queuing layout action: %w", err)
}
updates := waveobj.ContextGetUpdatesRtn(ctx)
sendWStoreUpdatesToEventBus(updates)
return &waveobj.ORef{OType: waveobj.OType_Block, OID: blockRef.OID}, nil
}