From 6371d95eb83079683b1589ef0d39475257bb1dab Mon Sep 17 00:00:00 2001 From: David Sehnal <david.sehnal@gmail.com> Date: Sun, 10 Feb 2019 21:13:35 +0100 Subject: [PATCH] mol-state: "silent" update --- src/mol-plugin/context.ts | 2 +- src/mol-state/state.ts | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/mol-plugin/context.ts b/src/mol-plugin/context.ts index 26fb5b3a2..17cd0f5ed 100644 --- a/src/mol-plugin/context.ts +++ b/src/mol-plugin/context.ts @@ -146,7 +146,7 @@ export class PluginContext { tree.toRoot().apply(b.transformer, b.defaultParams, { ref: b.transformer.id }); } - await this.runTask(this.state.behaviorState.update(tree)); + await this.runTask(this.state.behaviorState.update(tree, true)); } initDataActions() { diff --git a/src/mol-state/state.ts b/src/mol-state/state.ts index 9aa7fa3c9..9733c06ad 100644 --- a/src/mol-state/state.ts +++ b/src/mol-state/state.ts @@ -118,7 +118,7 @@ class State { }); } - update(tree: StateTree | StateTreeBuilder): Task<void> { + update(tree: StateTree | StateTreeBuilder, silent: boolean = false): Task<void> { const _tree = (StateTreeBuilder.is(tree) ? tree.getTree() : tree).asTransient(); return Task.create('Update Tree', async taskCtx => { let updated = false; @@ -139,6 +139,8 @@ class State { results: [], + silent, + changed: false, hadError: false, newCurrent: void 0 @@ -209,6 +211,9 @@ interface UpdateContext { results: UpdateNodeResult[], + // suppress timing messages + silent: boolean, + changed: boolean, hadError: boolean, newCurrent?: Ref @@ -492,13 +497,13 @@ async function updateSubtree(ctx: UpdateContext, root: Ref) { ctx.results.push(update); if (update.action === 'created') { isNull = update.obj === StateObject.Null; - if (!isNull) ctx.parent.events.log.next(LogEntry.info(`Created ${update.obj.label} in ${formatTimespan(time)}.`)); + if (!isNull && !ctx.silent) ctx.parent.events.log.next(LogEntry.info(`Created ${update.obj.label} in ${formatTimespan(time)}.`)); } else if (update.action === 'updated') { isNull = update.obj === StateObject.Null; - if (!isNull) ctx.parent.events.log.next(LogEntry.info(`Updated ${update.obj.label} in ${formatTimespan(time)}.`)); + if (!isNull && !ctx.silent) ctx.parent.events.log.next(LogEntry.info(`Updated ${update.obj.label} in ${formatTimespan(time)}.`)); } else if (update.action === 'replaced') { isNull = update.obj === StateObject.Null; - if (!isNull) ctx.parent.events.log.next(LogEntry.info(`Updated ${update.obj.label} in ${formatTimespan(time)}.`)); + if (!isNull && !ctx.silent) ctx.parent.events.log.next(LogEntry.info(`Updated ${update.obj.label} in ${formatTimespan(time)}.`)); } } catch (e) { ctx.changed = true; -- GitLab