mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🎨 Refresh virtual block ref when closing box https://github.com/siyuan-note/siyuan/issues/11149#issuecomment-2106254491
This commit is contained in:
parent
b959cc2beb
commit
60380f5dee
4 changed files with 21 additions and 16 deletions
|
|
@ -503,6 +503,10 @@ func genTreeID(tree *parse.Tree) {
|
||||||
func FullReindex() {
|
func FullReindex() {
|
||||||
task.AppendTask(task.DatabaseIndexFull, fullReindex)
|
task.AppendTask(task.DatabaseIndexFull, fullReindex)
|
||||||
task.AppendTask(task.DatabaseIndexRef, IndexRefs)
|
task.AppendTask(task.DatabaseIndexRef, IndexRefs)
|
||||||
|
go func() {
|
||||||
|
sql.WaitForWritingDatabase()
|
||||||
|
ResetVirtualBlockRefCache()
|
||||||
|
}()
|
||||||
task.AppendTaskWithTimeout(task.DatabaseIndexEmbedBlock, 30*time.Second, autoIndexEmbedBlock)
|
task.AppendTaskWithTimeout(task.DatabaseIndexEmbedBlock, 30*time.Second, autoIndexEmbedBlock)
|
||||||
cache.ClearDocsIAL()
|
cache.ClearDocsIAL()
|
||||||
cache.ClearBlocksIAL()
|
cache.ClearBlocksIAL()
|
||||||
|
|
|
||||||
|
|
@ -106,23 +106,26 @@ func listSyFiles(dir string) (ret []string) {
|
||||||
|
|
||||||
func (box *Box) Unindex() {
|
func (box *Box) Unindex() {
|
||||||
task.AppendTask(task.DatabaseIndex, unindex, box.ID)
|
task.AppendTask(task.DatabaseIndex, unindex, box.ID)
|
||||||
}
|
|
||||||
|
|
||||||
func unindex(boxID string) {
|
|
||||||
ids := treenode.RemoveBlockTreesByBoxID(boxID)
|
|
||||||
RemoveRecentDoc(ids)
|
|
||||||
sql.DeleteBoxQueue(boxID)
|
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
sql.WaitForWritingDatabase()
|
sql.WaitForWritingDatabase()
|
||||||
ResetVirtualBlockRefCache()
|
ResetVirtualBlockRefCache()
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func unindex(boxID string) {
|
||||||
|
ids := treenode.RemoveBlockTreesByBoxID(boxID)
|
||||||
|
RemoveRecentDoc(ids)
|
||||||
|
sql.DeleteBoxQueue(boxID)
|
||||||
|
}
|
||||||
|
|
||||||
func (box *Box) Index() {
|
func (box *Box) Index() {
|
||||||
task.AppendTask(task.DatabaseIndexRef, removeBoxRefs, box.ID)
|
task.AppendTask(task.DatabaseIndexRef, removeBoxRefs, box.ID)
|
||||||
task.AppendTask(task.DatabaseIndex, index, box.ID)
|
task.AppendTask(task.DatabaseIndex, index, box.ID)
|
||||||
task.AppendTask(task.DatabaseIndexRef, IndexRefs)
|
task.AppendTask(task.DatabaseIndexRef, IndexRefs)
|
||||||
|
go func() {
|
||||||
|
sql.WaitForWritingDatabase()
|
||||||
|
ResetVirtualBlockRefCache()
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeBoxRefs(boxID string) {
|
func removeBoxRefs(boxID string) {
|
||||||
|
|
@ -286,8 +289,6 @@ func IndexRefs() {
|
||||||
}
|
}
|
||||||
logging.LogInfof("resolved refs [%d] in [%dms]", size, time.Now().Sub(start).Milliseconds())
|
logging.LogInfof("resolved refs [%d] in [%dms]", size, time.Now().Sub(start).Milliseconds())
|
||||||
util.PushStatusBar(fmt.Sprintf(Conf.Language(55), i))
|
util.PushStatusBar(fmt.Sprintf(Conf.Language(55), i))
|
||||||
|
|
||||||
ResetVirtualBlockRefCache()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var indexEmbedBlockLock = sync.Mutex{}
|
var indexEmbedBlockLock = sync.Mutex{}
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ import (
|
||||||
"github.com/siyuan-note/logging"
|
"github.com/siyuan-note/logging"
|
||||||
"github.com/siyuan-note/siyuan/kernel/conf"
|
"github.com/siyuan-note/siyuan/kernel/conf"
|
||||||
"github.com/siyuan-note/siyuan/kernel/filesys"
|
"github.com/siyuan-note/siyuan/kernel/filesys"
|
||||||
|
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||||
"github.com/siyuan-note/siyuan/kernel/task"
|
"github.com/siyuan-note/siyuan/kernel/task"
|
||||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
|
|
@ -649,6 +650,10 @@ func checkoutRepo(id string) {
|
||||||
|
|
||||||
task.AppendTask(task.DatabaseIndexFull, fullReindex)
|
task.AppendTask(task.DatabaseIndexFull, fullReindex)
|
||||||
task.AppendTask(task.DatabaseIndexRef, IndexRefs)
|
task.AppendTask(task.DatabaseIndexRef, IndexRefs)
|
||||||
|
go func() {
|
||||||
|
sql.WaitForWritingDatabase()
|
||||||
|
ResetVirtualBlockRefCache()
|
||||||
|
}()
|
||||||
task.AppendTask(task.ReloadUI, util.ReloadUIResetScroll)
|
task.AppendTask(task.ReloadUI, util.ReloadUIResetScroll)
|
||||||
|
|
||||||
if syncEnabled {
|
if syncEnabled {
|
||||||
|
|
|
||||||
|
|
@ -106,8 +106,8 @@ func CacheVirtualBlockRefJob() {
|
||||||
task.AppendTask(task.CacheVirtualBlockRef, ResetVirtualBlockRefCache)
|
task.AppendTask(task.CacheVirtualBlockRef, ResetVirtualBlockRefCache)
|
||||||
}
|
}
|
||||||
|
|
||||||
func cacheVirtualBlockRef() {
|
func ResetVirtualBlockRefCache() {
|
||||||
virtualBlockRefCache.Del("virtual_ref")
|
virtualBlockRefCache.Clear()
|
||||||
if !Conf.Editor.VirtualBlockRef {
|
if !Conf.Editor.VirtualBlockRef {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -116,11 +116,6 @@ func cacheVirtualBlockRef() {
|
||||||
virtualBlockRefCache.Set("virtual_ref", keywords, 1)
|
virtualBlockRefCache.Set("virtual_ref", keywords, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ResetVirtualBlockRefCache() {
|
|
||||||
virtualBlockRefCache.Clear()
|
|
||||||
cacheVirtualBlockRef()
|
|
||||||
}
|
|
||||||
|
|
||||||
func AddVirtualBlockRefInclude(keyword []string) {
|
func AddVirtualBlockRefInclude(keyword []string) {
|
||||||
if 1 > len(keyword) {
|
if 1 > len(keyword) {
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue