add root MergeIn
This commit is contained in:
@@ -18,3 +18,21 @@ func (root *Root) MoveScheduledToTodo() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (root *Root) MergeIn(root2 Root) {
|
||||
for _, listPair := range [][2]*[]Todo{
|
||||
[2]*[]Todo{&root.Todo, &root2.Todo},
|
||||
[2]*[]Todo{&root.Scheduled, &root2.Scheduled},
|
||||
[2]*[]Todo{&root.Done, &root2.Done},
|
||||
} {
|
||||
for _, candidate := range *listPair[1] {
|
||||
found := false
|
||||
for i := range *listPair[0] {
|
||||
found = found || ((*listPair[0])[i].Todo == candidate.Todo)
|
||||
}
|
||||
if !found {
|
||||
*listPair[0] = append(*listPair[0], candidate)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user