mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-26 17:04:07 +01:00
♻️ Extract method util.GetTreeID
This commit is contained in:
parent
c295a496d7
commit
6f7e106be4
11 changed files with 26 additions and 27 deletions
|
|
@ -310,7 +310,7 @@ func ListDocTree(boxID, listPath string, sortMode int, flashcard, showHidden boo
|
|||
}
|
||||
|
||||
if flashcard {
|
||||
rootID := strings.TrimSuffix(filepath.Base(parentDocPath), ".sy")
|
||||
rootID := util.GetTreeID(parentDocPath)
|
||||
newFlashcardCount, dueFlashcardCount, flashcardCount := countTreeFlashcard(rootID, deck, deckBlockIDs)
|
||||
if 0 < flashcardCount {
|
||||
doc.NewFlashcardCount = newFlashcardCount
|
||||
|
|
@ -339,7 +339,7 @@ func ListDocTree(boxID, listPath string, sortMode int, flashcard, showHidden boo
|
|||
doc := box.docFromFileInfo(file, ial)
|
||||
|
||||
if flashcard {
|
||||
rootID := strings.TrimSuffix(filepath.Base(file.path), ".sy")
|
||||
rootID := util.GetTreeID(file.path)
|
||||
newFlashcardCount, dueFlashcardCount, flashcardCount := countTreeFlashcard(rootID, deck, deckBlockIDs)
|
||||
if 0 < flashcardCount {
|
||||
doc.NewFlashcardCount = newFlashcardCount
|
||||
|
|
@ -1833,7 +1833,7 @@ func createDoc(boxID, p, title, dom string) (tree *parse.Tree, err error) {
|
|||
}
|
||||
|
||||
baseName := strings.TrimSpace(path.Base(p))
|
||||
if "" == strings.TrimSuffix(baseName, ".sy") {
|
||||
if "" == util.GetTreeID(baseName) {
|
||||
err = errors.New(Conf.Language(16))
|
||||
return
|
||||
}
|
||||
|
|
@ -1849,7 +1849,7 @@ func createDoc(boxID, p, title, dom string) (tree *parse.Tree, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
id := strings.TrimSuffix(path.Base(p), ".sy")
|
||||
id := util.GetTreeID(p)
|
||||
var hPath string
|
||||
folder := path.Dir(p)
|
||||
if "/" != folder {
|
||||
|
|
@ -2006,7 +2006,7 @@ func ChangeFileTreeSort(boxID string, paths []string) {
|
|||
sortIDs := map[string]int{}
|
||||
max := 0
|
||||
for i, p := range paths {
|
||||
id := strings.TrimSuffix(path.Base(p), ".sy")
|
||||
id := util.GetTreeID(p)
|
||||
sortIDs[id] = i + 1
|
||||
if i == len(paths)-1 {
|
||||
max = i + 2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue