mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
reduce flickering of import by disabling entityChanges notification of frontend
This commit is contained in:
parent
5542c9dc57
commit
e78b495bd3
@ -42,6 +42,9 @@ async function importToBranch(req) {
|
||||
// and may produce unintended consequences
|
||||
cls.disableEntityEvents();
|
||||
|
||||
// eliminate flickering during import
|
||||
cls.ignoreEntityChanges();
|
||||
|
||||
let note; // typically root of the import - client can show it after finishing the import
|
||||
|
||||
const taskContext = TaskContext.getInstance(taskId, 'import', options);
|
||||
|
@ -53,6 +53,10 @@ function getAndClearEntityChanges() {
|
||||
}
|
||||
|
||||
function addEntityChange(entityChange) {
|
||||
if (namespace.get('ignoreEntityChanges')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const entityChanges = namespace.get('entityChanges') || [];
|
||||
|
||||
entityChanges.push(entityChange);
|
||||
@ -69,7 +73,11 @@ function getEntityFromCache(entityName, entityId) {
|
||||
}
|
||||
|
||||
function setEntityToCache(entityName, entityId, entity) {
|
||||
return namespace.set(entityName + '-' + entityId, entity);
|
||||
namespace.set(entityName + '-' + entityId, entity);
|
||||
}
|
||||
|
||||
function ignoreEntityChanges() {
|
||||
namespace.set('ignoreEntityChanges', true);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
@ -87,5 +95,6 @@ module.exports = {
|
||||
getAndClearEntityChanges,
|
||||
addEntityChange,
|
||||
getEntityFromCache,
|
||||
setEntityToCache
|
||||
setEntityToCache,
|
||||
ignoreEntityChanges
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user