mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-04 03:01:14 +08:00
🎨 Database table view cell value adds createdAt
and updatedAt
fields https://github.com/siyuan-note/siyuan/issues/10492
This commit is contained in:
parent
e487897b54
commit
ce58bccd63
@ -91,10 +91,11 @@ func (value *Value) Compare(other *Value) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !value.IsEdited() {
|
if !value.IsEdited() {
|
||||||
return 1
|
if other.IsEdited() {
|
||||||
}
|
return 1
|
||||||
|
}
|
||||||
if !other.IsEdited() {
|
return int(value.CreatedAt - other.CreatedAt)
|
||||||
|
} else if !other.IsEdited() {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,8 +184,12 @@ func (value *Value) Clone() (ret *Value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (value *Value) IsEdited() bool {
|
func (value *Value) IsEdited() bool {
|
||||||
|
if 1709454120000 > value.CreatedAt {
|
||||||
|
// 说明是旧数据,认为都是编辑过的
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
if value.CreatedAt == value.UpdatedAt {
|
if value.CreatedAt == value.UpdatedAt {
|
||||||
// 说明是刚刚创建的块
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
@ -976,7 +976,23 @@ func FillAttributeViewTableCellNilValue(tableCell *av.TableCell, rowID, colID st
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetAttributeViewDefaultValue(valueID, keyID, blockID string, typ av.KeyType) (ret *av.Value) {
|
func GetAttributeViewDefaultValue(valueID, keyID, blockID string, typ av.KeyType) (ret *av.Value) {
|
||||||
|
if "" == valueID {
|
||||||
|
valueID = ast.NewNodeID()
|
||||||
|
}
|
||||||
|
|
||||||
ret = &av.Value{ID: valueID, KeyID: keyID, BlockID: blockID, Type: typ}
|
ret = &av.Value{ID: valueID, KeyID: keyID, BlockID: blockID, Type: typ}
|
||||||
|
|
||||||
|
createdStr := valueID[:len("20060102150405")]
|
||||||
|
created, parseErr := time.ParseInLocation("20060102150405", createdStr, time.Local)
|
||||||
|
if nil == parseErr {
|
||||||
|
ret.CreatedAt = created.UnixMilli()
|
||||||
|
} else {
|
||||||
|
ret.CreatedAt = time.Now().UnixMilli()
|
||||||
|
}
|
||||||
|
if 0 == ret.UpdatedAt {
|
||||||
|
ret.UpdatedAt = ret.CreatedAt
|
||||||
|
}
|
||||||
|
|
||||||
switch typ {
|
switch typ {
|
||||||
case av.KeyTypeText:
|
case av.KeyTypeText:
|
||||||
ret.Text = &av.ValueText{}
|
ret.Text = &av.ValueText{}
|
||||||
|
Loading…
Reference in New Issue
Block a user