🎨 重建索引细节进度推送展现 https://github.com/siyuan-note/siyuan/issues/5890

This commit is contained in:
Liang Ding 2022-09-16 11:04:52 +08:00
parent 9a7f61f715
commit e52883fc3e
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
9 changed files with 89 additions and 133 deletions

View file

@ -1,46 +0,0 @@
// SiYuan - Build Your Eternal Digital Garden
// Copyright (c) 2020-present, b3log.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package sql
import (
"github.com/siyuan-note/siyuan/kernel/util"
)
const (
EvtSQLInsertBlocks = "sql.insert.blocks"
EvtSQLInsertBlocksFTS = "sql.insert.blocks_fts"
)
const (
CtxPushMsg = "pushMsg"
CtxPushMsgToProgress = iota
CtxPushMsgToStatusBar
CtxPushMsgToStatusBarAndProgress
)
func contextPushMsg(context map[string]interface{}, msg string) {
switch context[CtxPushMsg].(int) {
case CtxPushMsgToProgress:
util.PushEndlessProgress(msg)
case CtxPushMsgToStatusBar:
util.PushStatusBar(msg)
case CtxPushMsgToStatusBarAndProgress:
util.PushStatusBar(msg)
util.PushEndlessProgress(msg)
}
}

View file

@ -27,6 +27,7 @@ import (
"github.com/88250/lute/parse"
"github.com/emirpasic/gods/sets/hashset"
"github.com/siyuan-note/eventbus"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/util"
)
@ -98,7 +99,7 @@ func flushTreeQueue() {
return
}
context := map[string]interface{}{CtxPushMsg: CtxPushMsgToStatusBar}
context := map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
boxes := hashset.New()
for _, op := range ops {
switch op.action {

View file

@ -128,7 +128,7 @@ func insertBlocks0(tx *sql.Tx, bulk []*Block, context map[string]interface{}) (e
}
hashBuf.WriteString("blocks")
evtHash := fmt.Sprintf("%x", sha256.Sum256(hashBuf.Bytes()))[:7]
eventbus.Publish(EvtSQLInsertBlocks, context, len(bulk), evtHash)
eventbus.Publish(eventbus.EvtSQLInsertBlocks, context, len(bulk), evtHash)
stmt = fmt.Sprintf(BlocksFTSInsert, strings.Join(valueStrings, ","))
if err = prepareExecInsertTx(tx, stmt, valueArgs); nil != err {
@ -143,7 +143,7 @@ func insertBlocks0(tx *sql.Tx, bulk []*Block, context map[string]interface{}) (e
}
hashBuf.WriteString("fts")
evtHash = fmt.Sprintf("%x", sha256.Sum256(hashBuf.Bytes()))[:7]
eventbus.Publish(EvtSQLInsertBlocksFTS, context, len(bulk), evtHash)
eventbus.Publish(eventbus.EvtSQLInsertBlocksFTS, context, len(bulk), evtHash)
return
}