Skip to content

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

:recycle: Implement some delayed kernel events using task queues https://github.com/siyuan-note/siyuan/issues/12393

Danielffe737f55c1a
diff --git a/kernel/model/cloud_service.go b/kernel/model/cloud_service.go
index da7bae761d..c4b6ab2b7e 100644
--- a/kernel/model/cloud_service.go
+++ b/kernel/model/cloud_service.go
@@ -33,6 +33,7 @@ import (
"github.com/siyuan-note/httpclient"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/conf"
+ "github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/util"
)
@@ -238,8 +239,7 @@ func refreshSubscriptionExpirationRemind() {
now := time.Now().UnixMilli()
if now >= expired { // 已经过期
if now-expired <= 1000*60*60*24*2 { // 2 天内提醒 https://github.com/siyuan-note/siyuan/issues/7816
- time.Sleep(time.Second * 30)
- util.PushErrMsg(Conf.Language(128), 0)
+ task.AppendTaskWithDelay(task.PushMsg, 30*time.Second, util.PushErrMsg, Conf.Language(128), 0)
}
return
}
@@ -251,8 +251,7 @@ func refreshSubscriptionExpirationRemind() {
if 0 < remains && expireDay > remains {
util.WaitForUILoaded()
- time.Sleep(time.Second * 7)
- util.PushErrMsg(fmt.Sprintf(Conf.Language(127), remains), 0)
+ task.AppendTaskWithDelay(task.PushMsg, 7*time.Second, util.PushErrMsg, fmt.Sprintf(Conf.Language(127), remains), 0)
return
}
}
diff --git a/kernel/model/index_fix.go b/kernel/model/index_fix.go
index 967a57db22..913acf16f1 100644
--- a/kernel/model/index_fix.go
+++ b/kernel/model/index_fix.go
@@ -257,8 +257,8 @@ func resetDuplicateBlocksOnFileSys() {
if needRefreshUI {
util.ReloadUI()
go func() {
- time.Sleep(time.Second * 3)
- util.PushMsg(Conf.Language(190), 5000)
+ util.WaitForUILoaded()
+ task.AppendTaskWithDelay(task.PushMsg, 3*time.Second, util.PushMsg, Conf.Language(190), 5000)
}()
}
}
diff --git a/kernel/model/mount.go b/kernel/model/mount.go
index 7c83fcdf15..e030927350 100644
--- a/kernel/model/mount.go
+++ b/kernel/model/mount.go
@@ -30,6 +30,7 @@ import (
"github.com/88250/lute/ast"
"github.com/siyuan-note/filelock"
"github.com/siyuan-note/logging"
+ "github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/util"
)
@@ -218,10 +219,8 @@ func Mount(boxID string) (alreadyMount bool, err error) {
Conf.Save()
}
+ task.AppendTaskWithDelay(task.PushMsg, 3*time.Second, util.PushErrMsg, Conf.Language(52), 7000)
go func() {
- time.Sleep(time.Second * 3)
- util.PushErrMsg(Conf.Language(52), 7000)
-
// 每次打开帮助文档时自动检查版本更新并提醒 https://github.com/siyuan-note/siyuan/issues/5057
time.Sleep(time.Second * 10)
CheckUpdate(true)