mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 15:40:12 +01:00
🐛 setAttributesViewGroup timing error (#16275)
* fix: "Cannot read properties of undefined (reading 'forEach')" when creating kanban view - fixed error when `setAttributeViewGroup()` tries to access `attrView.Views` before kanban view is added * fix: "Failed to execute 'json' on 'Response': Unexpected end of JSON input" when converting to kanban view - fixed error where `ChangeAttrViewLayout()` generates groups before new layout type is set, causing data structure mismatch
This commit is contained in:
parent
8ae922cd15
commit
c72f2b0167
1 changed files with 8 additions and 6 deletions
|
|
@ -721,6 +721,8 @@ func ChangeAttrViewLayout(blockID, avID string, layout av.LayoutType) (err error
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
view.LayoutType = newLayout
|
||||||
|
|
||||||
switch newLayout {
|
switch newLayout {
|
||||||
case av.LayoutTypeTable:
|
case av.LayoutTypeTable:
|
||||||
if view.Name == av.GetAttributeViewI18n("gallery") || view.Name == av.GetAttributeViewI18n("kanban") {
|
if view.Name == av.GetAttributeViewI18n("gallery") || view.Name == av.GetAttributeViewI18n("kanban") {
|
||||||
|
|
@ -788,8 +790,6 @@ func ChangeAttrViewLayout(blockID, avID string, layout av.LayoutType) (err error
|
||||||
setAttributeViewGroup(attrView, view, group)
|
setAttributeViewGroup(attrView, view, group)
|
||||||
}
|
}
|
||||||
|
|
||||||
view.LayoutType = newLayout
|
|
||||||
|
|
||||||
blockIDs := treenode.GetMirrorAttrViewBlockIDs(avID)
|
blockIDs := treenode.GetMirrorAttrViewBlockIDs(avID)
|
||||||
for _, bID := range blockIDs {
|
for _, bID := range blockIDs {
|
||||||
node, tree, _ := getNodeByBlockID(nil, bID)
|
node, tree, _ := getNodeByBlockID(nil, bID)
|
||||||
|
|
@ -2860,10 +2860,6 @@ func addAttrViewView(avID, viewID, blockID string, layout av.LayoutType) (err er
|
||||||
view.Kanban.Fields = append(view.Kanban.Fields, &av.ViewKanbanField{BaseField: &av.BaseField{ID: field.ID}})
|
view.Kanban.Fields = append(view.Kanban.Fields, &av.ViewKanbanField{BaseField: &av.BaseField{ID: field.ID}})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
preferredGroupKey := getKanbanPreferredGroupKey(attrView)
|
|
||||||
group := &av.ViewGroup{Field: preferredGroupKey.ID}
|
|
||||||
setAttributeViewGroup(attrView, view, group)
|
|
||||||
default:
|
default:
|
||||||
err = av.ErrWrongLayoutType
|
err = av.ErrWrongLayoutType
|
||||||
logging.LogErrorf("wrong layout type [%s] for attribute view [%s]", layout, avID)
|
logging.LogErrorf("wrong layout type [%s] for attribute view [%s]", layout, avID)
|
||||||
|
|
@ -2875,6 +2871,12 @@ func addAttrViewView(avID, viewID, blockID string, layout av.LayoutType) (err er
|
||||||
view.ID = viewID
|
view.ID = viewID
|
||||||
attrView.Views = append(attrView.Views, view)
|
attrView.Views = append(attrView.Views, view)
|
||||||
|
|
||||||
|
if av.LayoutTypeKanban == layout {
|
||||||
|
preferredGroupKey := getKanbanPreferredGroupKey(attrView)
|
||||||
|
group := &av.ViewGroup{Field: preferredGroupKey.ID}
|
||||||
|
setAttributeViewGroup(attrView, view, group)
|
||||||
|
}
|
||||||
|
|
||||||
node, tree, _ := getNodeByBlockID(nil, blockID)
|
node, tree, _ := getNodeByBlockID(nil, blockID)
|
||||||
if nil == node {
|
if nil == node {
|
||||||
logging.LogErrorf("get node by block ID [%s] failed", blockID)
|
logging.LogErrorf("get node by block ID [%s] failed", blockID)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue