Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve av https://github.com/siyuan-note/siyuan/issues/15498

Daniel96346a94adc0
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index 2ab2401183..a73c075550 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -174,7 +174,7 @@ func sortAttributeViewGroup(avID, blockID, previousGroupID, groupID string) (err
return err
}
- sortGroupViews(time.Now(), view)
+ sortGroupViews(view)
var groupView *av.View
var index, previousIndex int
diff --git a/kernel/model/attribute_view_render.go b/kernel/model/attribute_view_render.go
index 0be3f494fa..37e8051732 100644
--- a/kernel/model/attribute_view_render.go
+++ b/kernel/model/attribute_view_render.go
@@ -137,9 +137,7 @@ func renderAttributeViewGroups(viewable av.Viewable, attrView *av.AttributeView,
}
}
- todayStart := time.Now()
- todayStart = time.Date(todayStart.Year(), todayStart.Month(), todayStart.Day(), 0, 0, 0, 0, time.Local)
- sortGroupViews(todayStart, view)
+ sortGroupViews(view)
var groups []av.Viewable
for _, groupView := range view.Groups {
@@ -195,7 +193,7 @@ func hideEmptyGroupViews(view *av.View, viewable av.Viewable) {
}
}
-func sortGroupViews(todayStart time.Time, view *av.View) {
+func sortGroupViews(view *av.View) {
if av.GroupOrderMan == view.Group.Order {
sort.Slice(view.Groups, func(i, j int) bool { return view.Groups[i].GroupSort < view.Groups[j].GroupSort })
return
@@ -259,6 +257,7 @@ func sortGroupViews(todayStart time.Time, view *av.View) {
}
startIdx := -1
+ todayStart := util.GetTodayStart()
thisMonth := todayStart.Format("2006-01")
for i, monthGroup := range relativeDateGroups {
if monthGroup.GetGroupValue() < thisMonth {
diff --git a/kernel/util/time.go b/kernel/util/time.go
index b22c6c9370..bd9fad5ea1 100644
--- a/kernel/util/time.go
+++ b/kernel/util/time.go
@@ -26,6 +26,12 @@ import (
"github.com/88250/go-humanize"
)
+func GetTodayStart() (ret time.Time) {
+ ret = time.Now()
+ ret = time.Date(ret.Year(), ret.Month(), ret.Day(), 0, 0, 0, 0, time.Local)
+ return
+}
+
// Weekday returns the day of the week specified by date.
// Sunday=0, Monday=1, ..., Saturday=6.
func Weekday(date time.Time) int {