From ae24e46eceb2bfadb00d632d43f31a387afaaee5 Mon Sep 17 00:00:00 2001 From: sawka Date: Tue, 28 May 2024 21:08:00 -0700 Subject: [PATCH] start blockcontrollers on switch tab --- pkg/service/objectservice/objectservice.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/service/objectservice/objectservice.go b/pkg/service/objectservice/objectservice.go index 372ec1b77..1d047acdf 100644 --- a/pkg/service/objectservice/objectservice.go +++ b/pkg/service/objectservice/objectservice.go @@ -7,6 +7,7 @@ import ( "context" "encoding/json" "fmt" + "log" "strings" "time" @@ -108,6 +109,19 @@ func (svc *ObjectService) SetActiveTab(uiContext wstore.UIContext, tabId string) if err != nil { return nil, fmt.Errorf("error setting active tab: %w", err) } + // check all blocks in tab and start controllers (if necessary) + tab, err := wstore.DBMustGet[*wstore.Tab](ctx, tabId) + if err != nil { + return nil, fmt.Errorf("error getting tab: %w", err) + } + for _, blockId := range tab.BlockIds { + blockErr := blockcontroller.StartBlockController(ctx, blockId) + if blockErr != nil { + // we don't want to fail the set active tab operation if a block controller fails to start + log.Printf("error starting block controller (blockid:%s): %w", blockId, blockErr) + continue + } + } return updatesRtn(ctx, nil) }