reduce flickering of import by disabling entityChanges notification of frontend

This commit is contained in:
zadam 2021-02-16 22:51:00 +01:00
parent 5542c9dc57
commit e78b495bd3
2 changed files with 14 additions and 2 deletions

View file

@ -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);

View file

@ -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
};