mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-02-28 05:32:52 +00:00
♻️ Implement some delayed kernel events using task queues https://github.com/siyuan-note/siyuan/issues/12393
This commit is contained in:
@@ -45,8 +45,13 @@ var UseSingleLineSave = true
|
||||
var IsUILoaded = false
|
||||
|
||||
func WaitForUILoaded() {
|
||||
start := time.Now()
|
||||
for !IsUILoaded {
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
if time.Since(start) > 30*time.Second {
|
||||
logging.LogErrorf("wait for ui loaded timeout")
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -153,23 +153,27 @@ func PushTxErr(msg string, code int, data interface{}) {
|
||||
}
|
||||
|
||||
func PushUpdateMsg(msgId string, msg string, timeout int) {
|
||||
WaitForUILoaded()
|
||||
BroadcastByType("main", "msg", 0, msg, map[string]interface{}{"id": msgId, "closeTimeout": timeout})
|
||||
return
|
||||
}
|
||||
|
||||
func PushMsg(msg string, timeout int) (msgId string) {
|
||||
WaitForUILoaded()
|
||||
msgId = gulu.Rand.String(7)
|
||||
BroadcastByType("main", "msg", 0, msg, map[string]interface{}{"id": msgId, "closeTimeout": timeout})
|
||||
return
|
||||
}
|
||||
|
||||
func PushErrMsg(msg string, timeout int) (msgId string) {
|
||||
WaitForUILoaded()
|
||||
msgId = gulu.Rand.String(7)
|
||||
BroadcastByType("main", "msg", -1, msg, map[string]interface{}{"id": msgId, "closeTimeout": timeout})
|
||||
return
|
||||
}
|
||||
|
||||
func PushStatusBar(msg string) {
|
||||
WaitForUILoaded()
|
||||
msg += " (" + time.Now().Format("2006-01-02 15:04:05") + ")"
|
||||
BroadcastByType("main", "statusbar", 0, msg, nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user