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

mol-state: do not show time for null objects; better multi-select params comparison

parent 31a26f25
No related branches found
No related tags found
No related merge requests found
...@@ -474,13 +474,13 @@ async function updateSubtree(ctx: UpdateContext, root: Ref) { ...@@ -474,13 +474,13 @@ async function updateSubtree(ctx: UpdateContext, root: Ref) {
ctx.results.push(update); ctx.results.push(update);
if (update.action === 'created') { if (update.action === 'created') {
isNull = update.obj === StateObject.Null; isNull = update.obj === StateObject.Null;
ctx.parent.events.log.next(LogEntry.info(`Created ${update.obj.label} in ${formatTimespan(time)}.`)); if (!isNull) ctx.parent.events.log.next(LogEntry.info(`Created ${update.obj.label} in ${formatTimespan(time)}.`));
} else if (update.action === 'updated') { } else if (update.action === 'updated') {
isNull = update.obj === StateObject.Null; isNull = update.obj === StateObject.Null;
ctx.parent.events.log.next(LogEntry.info(`Updated ${update.obj.label} in ${formatTimespan(time)}.`)); if (!isNull) ctx.parent.events.log.next(LogEntry.info(`Updated ${update.obj.label} in ${formatTimespan(time)}.`));
} else if (update.action === 'replaced') { } else if (update.action === 'replaced') {
isNull = update.obj === StateObject.Null; isNull = update.obj === StateObject.Null;
ctx.parent.events.log.next(LogEntry.info(`Updated ${update.obj.label} in ${formatTimespan(time)}.`)); if (!isNull) ctx.parent.events.log.next(LogEntry.info(`Updated ${update.obj.label} in ${formatTimespan(time)}.`));
} }
} catch (e) { } catch (e) {
ctx.changed = true; ctx.changed = true;
......
...@@ -231,6 +231,23 @@ export namespace ParamDefinition { ...@@ -231,6 +231,23 @@ export namespace ParamDefinition {
if (u.name !== v.name) return false; if (u.name !== v.name) return false;
const map = p.map(u.name); const map = p.map(u.name);
return isParamEqual(map, u.params, v.params); return isParamEqual(map, u.params, v.params);
} else if (p.type === 'multi-select') {
const u = a as MultiSelect<any>['defaultValue'], v = b as MultiSelect<any>['defaultValue'];
if (u.length !== v.length) return false;
if (u.length < 10) {
for (let i = 0, _i = u.length; i < _i; i++) {
if (u[i] === v[i]) continue;
if (v.indexOf(u[i]) < 0) return false;
}
} else {
// TODO: should the value of multiselect be a set?
const vSet = new Set(v);
for (let i = 0, _i = u.length; i < _i; i++) {
if (u[i] === v[i]) continue;
if (!vSet.has(u[i])) return false;
}
}
return true;
} else if (p.type === 'interval') { } else if (p.type === 'interval') {
return a[0] === b[0] && a[1] === b[1]; return a[0] === b[0] && a[1] === b[1];
} else if (p.type === 'line-graph') { } else if (p.type === 'line-graph') {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment