mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
🎨 Refresh the data in the interface after moving the document https://github.com/siyuan-note/siyuan/issues/15762
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
d5e7b27a11
commit
ee4ddf89c1
6 changed files with 39 additions and 23 deletions
|
|
@ -14,12 +14,7 @@ import {fetchPost, fetchSyncPost} from "../../util/fetch";
|
||||||
import {openEmojiPanel, unicode2Emoji} from "../../emoji";
|
import {openEmojiPanel, unicode2Emoji} from "../../emoji";
|
||||||
import {mountHelp, newNotebook} from "../../util/mount";
|
import {mountHelp, newNotebook} from "../../util/mount";
|
||||||
import {confirmDialog} from "../../dialog/confirmDialog";
|
import {confirmDialog} from "../../dialog/confirmDialog";
|
||||||
import {
|
import {isNotCtrl, isOnlyMeta, setStorageVal, updateHotkeyAfterTip} from "../../protyle/util/compatibility";
|
||||||
isNotCtrl,
|
|
||||||
isOnlyMeta,
|
|
||||||
setStorageVal,
|
|
||||||
updateHotkeyAfterTip
|
|
||||||
} from "../../protyle/util/compatibility";
|
|
||||||
import {openFileById} from "../../editor/util";
|
import {openFileById} from "../../editor/util";
|
||||||
import {
|
import {
|
||||||
hasClosestByAttribute,
|
hasClosestByAttribute,
|
||||||
|
|
@ -1019,7 +1014,7 @@ data-type="navigation-root" data-path="/">
|
||||||
} else {
|
} else {
|
||||||
const parentElement = this.element.querySelector(`ul[data-url="${response.data.fromNotebook}"] li[data-path="${pathPosix().dirname(response.data.fromPath)}.sy"]`) as HTMLElement;
|
const parentElement = this.element.querySelector(`ul[data-url="${response.data.fromNotebook}"] li[data-path="${pathPosix().dirname(response.data.fromPath)}.sy"]`) as HTMLElement;
|
||||||
if (parentElement && parentElement.getAttribute("data-count") === "1") {
|
if (parentElement && parentElement.getAttribute("data-count") === "1") {
|
||||||
parentElement.querySelector(".b3-list-item__toggle").classList.add(".fn__hidden");
|
parentElement.querySelector(".b3-list-item__toggle").classList.add("fn__hidden");
|
||||||
parentElement.querySelector(".b3-list-item__arrow").classList.remove("b3-list-item__arrow--open");
|
parentElement.querySelector(".b3-list-item__arrow").classList.remove("b3-list-item__arrow--open");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -206,6 +206,12 @@ func DocIAL(absPath string) (ret map[string]string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TreeSize(tree *parse.Tree) (size uint64) {
|
||||||
|
luteEngine := util.NewLute() // 不关注用户的自定义解析渲染选项
|
||||||
|
renderer := render.NewJSONRenderer(tree, luteEngine.RenderOptions)
|
||||||
|
return uint64(len(renderer.Render()))
|
||||||
|
}
|
||||||
|
|
||||||
func WriteTree(tree *parse.Tree) (size uint64, err error) {
|
func WriteTree(tree *parse.Tree) (size uint64, err error) {
|
||||||
data, filePath, err := prepareWriteTree(tree)
|
data, filePath, err := prepareWriteTree(tree)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -473,6 +473,8 @@ func moveTree(tree *parse.Tree) {
|
||||||
|
|
||||||
box := Conf.Box(tree.Box)
|
box := Conf.Box(tree.Box)
|
||||||
box.renameSubTrees(tree)
|
box.renameSubTrees(tree)
|
||||||
|
|
||||||
|
refreshDocInfo(tree)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (box *Box) renameSubTrees(tree *parse.Tree) {
|
func (box *Box) renameSubTrees(tree *parse.Tree) {
|
||||||
|
|
|
||||||
|
|
@ -933,7 +933,7 @@ func writeTreeUpsertQueue(tree *parse.Tree) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sql.UpsertTreeQueue(tree)
|
sql.UpsertTreeQueue(tree)
|
||||||
refreshDocInfo(tree, size)
|
refreshDocInfoWithSize(tree, size)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -959,7 +959,7 @@ func renameWriteJSONQueue(tree *parse.Tree) (err error) {
|
||||||
}
|
}
|
||||||
sql.RenameTreeQueue(tree)
|
sql.RenameTreeQueue(tree)
|
||||||
treenode.UpsertBlockTree(tree)
|
treenode.UpsertBlockTree(tree)
|
||||||
refreshDocInfo(tree, size)
|
refreshDocInfoWithSize(tree, size)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1371,6 +1371,8 @@ func moveDoc(fromBox *Box, fromPath string, toBox *Box, toPath string, luteEngin
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fromParentTree := loadParentTree(tree)
|
||||||
|
|
||||||
moveToRoot := "/" == toPath
|
moveToRoot := "/" == toPath
|
||||||
toBlockID := tree.ID
|
toBlockID := tree.ID
|
||||||
fromFolder := path.Join(path.Dir(fromPath), tree.ID)
|
fromFolder := path.Join(path.Dir(fromPath), tree.ID)
|
||||||
|
|
@ -1489,6 +1491,8 @@ func moveDoc(fromBox *Box, fromPath string, toBox *Box, toPath string, luteEngin
|
||||||
}
|
}
|
||||||
evt.Callback = callback
|
evt.Callback = callback
|
||||||
util.PushEvent(evt)
|
util.PushEvent(evt)
|
||||||
|
|
||||||
|
refreshDocInfo(fromParentTree)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -38,25 +37,22 @@ import (
|
||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func refreshDocInfo(tree *parse.Tree, size uint64) {
|
func refreshDocInfo(tree *parse.Tree) {
|
||||||
|
refreshDocInfoWithSize(tree, filesys.TreeSize(tree))
|
||||||
|
}
|
||||||
|
|
||||||
|
func refreshDocInfoWithSize(tree *parse.Tree, size uint64) {
|
||||||
refreshDocInfo0(tree, size)
|
refreshDocInfo0(tree, size)
|
||||||
refreshParentDocInfo(tree)
|
refreshParentDocInfo(tree)
|
||||||
}
|
}
|
||||||
|
|
||||||
func refreshParentDocInfo(tree *parse.Tree) {
|
func refreshParentDocInfo(tree *parse.Tree) {
|
||||||
|
parentTree := loadParentTree(tree)
|
||||||
|
if nil == parentTree {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
luteEngine := lute.New()
|
luteEngine := lute.New()
|
||||||
boxDir := filepath.Join(util.DataDir, tree.Box)
|
|
||||||
parentDir := path.Dir(tree.Path)
|
|
||||||
if parentDir == boxDir || parentDir == "/" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
parentPath := parentDir + ".sy"
|
|
||||||
parentTree, err := filesys.LoadTree(tree.Box, parentPath, luteEngine)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
renderer := render.NewJSONRenderer(parentTree, luteEngine.RenderOptions)
|
renderer := render.NewJSONRenderer(parentTree, luteEngine.RenderOptions)
|
||||||
data := renderer.Render()
|
data := renderer.Render()
|
||||||
refreshDocInfo0(parentTree, uint64(len(data)))
|
refreshDocInfo0(parentTree, uint64(len(data)))
|
||||||
|
|
|
||||||
|
|
@ -305,3 +305,16 @@ func indexTreeInFilesystem(rootID string) {
|
||||||
sql.IndexTreeQueue(tree)
|
sql.IndexTreeQueue(tree)
|
||||||
logging.LogInfof("reindexed tree by filesystem [rootID=%s]", rootID)
|
logging.LogInfof("reindexed tree by filesystem [rootID=%s]", rootID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func loadParentTree(tree *parse.Tree) (ret *parse.Tree) {
|
||||||
|
boxDir := filepath.Join(util.DataDir, tree.Box)
|
||||||
|
parentDir := path.Dir(tree.Path)
|
||||||
|
if parentDir == boxDir || parentDir == "/" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
luteEngine := lute.New()
|
||||||
|
parentPath := parentDir + ".sy"
|
||||||
|
ret, _ = filesys.LoadTree(tree.Box, parentPath, luteEngine)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue