Skip to content
Snippets Groups Projects
Commit 6371d95e authored by David Sehnal's avatar David Sehnal
Browse files

mol-state: "silent" update

parent 952e082a
No related branches found
No related tags found
No related merge requests found
......@@ -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() {
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment