start blockcontrollers on switch tab

This commit is contained in:
sawka 2024-05-28 21:08:00 -07:00
parent 4d3ab0e822
commit ae24e46ece

View File

@ -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)
}