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