Fixed thread.go

graph-rework-2
noah metz 2023-07-21 00:06:11 -06:00
parent c3058fbd3d
commit 7435728321
1 changed files with 9 additions and 6 deletions

@ -305,7 +305,7 @@ func (thread * SimpleThread) SignalChannel() <-chan GraphSignal {
} }
type SimpleThreadJSON struct { type SimpleThreadJSON struct {
Parent *NodeID `json:"parent"` Parent string `json:"parent"`
Children map[string]interface{} `json:"children"` Children map[string]interface{} `json:"children"`
Timeout time.Time `json:"timeout"` Timeout time.Time `json:"timeout"`
TimeoutAction string `json:"timeout_action"` TimeoutAction string `json:"timeout_action"`
@ -319,10 +319,9 @@ func NewSimpleThreadJSON(thread *SimpleThread) SimpleThreadJSON {
children[child.ID().String()] = thread.child_info[child.ID()] children[child.ID().String()] = thread.child_info[child.ID()]
} }
var parent_id *NodeID = nil parent_id := ""
if thread.parent != nil { if thread.parent != nil {
new_str := thread.parent.ID() parent_id = thread.parent.ID().String()
parent_id = &new_str
} }
lockable_json := NewSimpleLockableJSON(&thread.SimpleLockable) lockable_json := NewSimpleLockableJSON(&thread.SimpleLockable)
@ -368,8 +367,12 @@ func RestoreSimpleThread(ctx *Context, thread Thread, j SimpleThreadJSON, nodes
thread.SetTimeout(j.Timeout, j.TimeoutAction) thread.SetTimeout(j.Timeout, j.TimeoutAction)
} }
if j.Parent != nil { if j.Parent != "" {
p, err := LoadNodeRecurse(ctx, *j.Parent, nodes) parent_id, err := ParseID(j.Parent)
if err != nil {
return err
}
p, err := LoadNodeRecurse(ctx, parent_id, nodes)
if err != nil { if err != nil {
return err return err
} }