♻️ Implement some delayed kernel events using task queues https://github.com/siyuan-note/siyuan/issues/12393
This commit is contained in:
parent
4f04ae98dd
commit
50adf9751b
6 changed files with 16 additions and 22 deletions
|
@ -246,11 +246,11 @@ const setSync = (key?: string, dialog?: Dialog) => {
|
|||
<button class="b3-button" disabled="disabled">${window.siyuan.languages.openSyncTip1}</button>
|
||||
</div>`;
|
||||
if (dialog) {
|
||||
dialog.element.querySelector(".b3-dialog__header").innerHTML = window.siyuan.languages.cloudSyncDir;
|
||||
dialog.element.querySelector(".b3-dialog__header").innerHTML = "🗂️ " + window.siyuan.languages.cloudSyncDir;
|
||||
dialog.element.querySelector(".b3-dialog__body").innerHTML = listHTML;
|
||||
} else {
|
||||
dialog = new Dialog({
|
||||
title: window.siyuan.languages.cloudSyncDir,
|
||||
title: "🗂️ " + window.siyuan.languages.cloudSyncDir,
|
||||
content: listHTML,
|
||||
width: isMobile() ? "92vw" : "520px",
|
||||
});
|
||||
|
@ -277,7 +277,7 @@ const setSync = (key?: string, dialog?: Dialog) => {
|
|||
fetchPost("/api/sync/setSyncEnable", {enabled: true}, () => {
|
||||
window.siyuan.config.sync.enabled = true;
|
||||
processSync();
|
||||
confirmDialog(window.siyuan.languages.syncConfGuide4, window.siyuan.languages.syncConfGuide5, () => {
|
||||
confirmDialog("🔄 " + window.siyuan.languages.syncConfGuide4, window.siyuan.languages.syncConfGuide5, () => {
|
||||
syncNow();
|
||||
});
|
||||
});
|
||||
|
@ -286,7 +286,7 @@ const setSync = (key?: string, dialog?: Dialog) => {
|
|||
if (dialog) {
|
||||
dialog.destroy();
|
||||
}
|
||||
confirmDialog(window.siyuan.languages.syncConfGuide4, window.siyuan.languages.syncConfGuide5, () => {
|
||||
confirmDialog("🔄 " + window.siyuan.languages.syncConfGuide4, window.siyuan.languages.syncConfGuide5, () => {
|
||||
syncNow();
|
||||
});
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ const setSync = (key?: string, dialog?: Dialog) => {
|
|||
|
||||
export const setKey = (isSync: boolean, cb?: () => void) => {
|
||||
const dialog = new Dialog({
|
||||
title: window.siyuan.languages.syncConfGuide1,
|
||||
title: "🔑 " + window.siyuan.languages.syncConfGuide1,
|
||||
content: `<div class="b3-dialog__content ft__center">
|
||||
<img style="width: 260px" src="/stage/images/sync-guide.svg"/>
|
||||
<div class="fn__hr--b"></div>
|
||||
|
|
|
@ -19,6 +19,7 @@ package model
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/siyuan-note/siyuan/kernel/task"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
@ -104,13 +105,10 @@ func BatchUpdateBazaarPackages(frontend string) {
|
|||
}
|
||||
|
||||
util.ReloadUI()
|
||||
|
||||
go func() {
|
||||
util.WaitForUILoaded()
|
||||
time.Sleep(500)
|
||||
util.PushMsg(fmt.Sprintf(Conf.language(237), total), 5000)
|
||||
task.AppendTaskWithDelay(task.PushMsg, 1*time.Second, util.PushMsg, fmt.Sprintf(Conf.language(237), total), 5000)
|
||||
}()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ package model
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/siyuan-note/siyuan/kernel/task"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
@ -468,11 +469,10 @@ func InitConf() {
|
|||
// 上次未正常完成数据索引
|
||||
go func() {
|
||||
util.WaitForUILoaded()
|
||||
time.Sleep(2 * time.Second)
|
||||
if util.ContainerIOS == util.Container || util.ContainerAndroid == util.Container {
|
||||
util.PushMsg(Conf.language(245), 15000)
|
||||
task.AppendTaskWithDelay(task.PushMsg, 2*time.Second, util.PushMsg, Conf.language(245), 15000)
|
||||
} else {
|
||||
util.PushMsg(Conf.language(244), 15000)
|
||||
task.AppendTaskWithDelay(task.PushMsg, 2*time.Second, util.PushMsg, Conf.language(244), 15000)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
|
|
@ -477,10 +477,7 @@ func ResetRepo() (err error) {
|
|||
Conf.Save()
|
||||
|
||||
util.PushUpdateMsg(msgId, Conf.Language(145), 3000)
|
||||
go func() {
|
||||
time.Sleep(2 * time.Second)
|
||||
util.ReloadUI()
|
||||
}()
|
||||
task.AppendTaskWithDelay(task.ReloadUI, 2*time.Second, util.ReloadUI)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -810,12 +810,9 @@ func syncDelete2AvBlock(node *ast.Node) {
|
|||
changedAvIDs = append(changedAvIDs, avIDs...)
|
||||
changedAvIDs = gulu.Str.RemoveDuplicatedElem(changedAvIDs)
|
||||
|
||||
go func() {
|
||||
time.Sleep(256 * time.Millisecond)
|
||||
for _, avID := range changedAvIDs {
|
||||
ReloadAttrView(avID)
|
||||
}
|
||||
}()
|
||||
for _, avID := range changedAvIDs {
|
||||
ReloadAttrView(avID)
|
||||
}
|
||||
}
|
||||
|
||||
func syncDelete2Block(node *ast.Node) (changedAvIDs []string) {
|
||||
|
|
|
@ -131,6 +131,7 @@ const (
|
|||
AssetContentDatabaseIndexCommit = "task.asset.database.index.commit" // 资源文件数据库索引提交
|
||||
CacheVirtualBlockRef = "task.cache.virtualBlockRef" // 缓存虚拟块引用
|
||||
ReloadAttributeView = "task.reload.attributeView" // 重新加载属性视图
|
||||
PushMsg = "task.push.msg" // 推送消息
|
||||
)
|
||||
|
||||
// uniqueActions 描述了唯一的任务,即队列中只能存在一个在执行的任务。
|
||||
|
@ -144,6 +145,7 @@ var uniqueActions = []string{
|
|||
HistoryDatabaseIndexCommit,
|
||||
AssetContentDatabaseIndexFull,
|
||||
AssetContentDatabaseIndexCommit,
|
||||
ReloadAttributeView,
|
||||
}
|
||||
|
||||
func ContainIndexTask() bool {
|
||||
|
|
Loading…
Add table
Reference in a new issue