mirror of
https://github.com/wavetermdev/backup.git
synced 2026-08-05 13:57:07 -07:00
app is working again. new structure for blocks. new useWaveObjectValueWithSuspense hook
This commit is contained in:
+25
-2
@@ -168,7 +168,8 @@ func (update WaveObjUpdate) MarshalJSON() ([]byte, error) {
|
||||
}
|
||||
|
||||
type UIContext struct {
|
||||
WindowId string `json:"windowid"`
|
||||
WindowId string `json:"windowid"`
|
||||
ActiveTabId string `json:"activetabid"`
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
@@ -239,7 +240,7 @@ type FileDef struct {
|
||||
}
|
||||
|
||||
type BlockDef struct {
|
||||
Controller string `json:"controller"`
|
||||
Controller string `json:"controller,omitempty"`
|
||||
View string `json:"view,omitempty"`
|
||||
Files map[string]*FileDef `json:"files,omitempty"`
|
||||
Meta map[string]any `json:"meta,omitempty"`
|
||||
@@ -317,6 +318,28 @@ func SetActiveTab(ctx context.Context, windowId string, tabId string) error {
|
||||
})
|
||||
}
|
||||
|
||||
func CreateBlock(ctx context.Context, tabId string, blockDef *BlockDef, rtOpts *RuntimeOpts) (*Block, error) {
|
||||
return WithTxRtn(ctx, func(tx *TxWrap) (*Block, error) {
|
||||
tab, _ := DBGet[*Tab](tx.Context(), tabId)
|
||||
if tab == nil {
|
||||
return nil, fmt.Errorf("tab not found: %q", tabId)
|
||||
}
|
||||
blockId := uuid.New().String()
|
||||
blockData := &Block{
|
||||
OID: blockId,
|
||||
BlockDef: blockDef,
|
||||
Controller: blockDef.Controller,
|
||||
View: blockDef.View,
|
||||
RuntimeOpts: rtOpts,
|
||||
Meta: blockDef.Meta,
|
||||
}
|
||||
DBInsert(tx.Context(), blockData)
|
||||
tab.BlockIds = append(tab.BlockIds, blockId)
|
||||
DBUpdate(tx.Context(), tab)
|
||||
return blockData, nil
|
||||
})
|
||||
}
|
||||
|
||||
func EnsureInitialData() error {
|
||||
// does not need to run in a transaction since it is called on startup
|
||||
ctx, cancelFn := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
|
||||
Reference in New Issue
Block a user