mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-29 04:48:48 +01:00
♻️ Refactor av data structure
This commit is contained in:
parent
3a3cb12bbf
commit
22a741c857
1 changed files with 6 additions and 10 deletions
|
|
@ -169,16 +169,18 @@ type Viewable interface {
|
|||
GetID() string
|
||||
}
|
||||
|
||||
func NewAttributeView(id string) *AttributeView {
|
||||
func NewAttributeView(id string) (ret *AttributeView) {
|
||||
view := NewView()
|
||||
|
||||
return &AttributeView{
|
||||
key := NewKey("Block", KeyTypeBlock)
|
||||
ret = &AttributeView{
|
||||
Spec: 0,
|
||||
ID: id,
|
||||
KeyValues: []*KeyValues{{Key: NewKey("Name", KeyTypeBlock)}},
|
||||
KeyValues: []*KeyValues{{Key: key}},
|
||||
CurrentViewID: view.ID,
|
||||
Views: []*View{view},
|
||||
}
|
||||
view.Table.Columns = []*ViewTableColumn{{ID: key.ID}}
|
||||
return
|
||||
}
|
||||
|
||||
func ParseAttributeView(avID string) (ret *AttributeView, err error) {
|
||||
|
|
@ -199,12 +201,6 @@ func ParseAttributeView(avID string) (ret *AttributeView, err error) {
|
|||
logging.LogErrorf("unmarshal attribute view [%s] failed: %s", avID, err)
|
||||
return
|
||||
}
|
||||
|
||||
if 1 > len(ret.Views) {
|
||||
view := NewView()
|
||||
ret.CurrentViewID = view.ID
|
||||
ret.Views = []*View{view}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue