Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,27 @@ const MAX_ERRORS = 20
// Identifies our own get_tlm_values poll as the source of a transient error
const POLL_ERROR_SOURCE = 'screen:get_tlm_values'

// Values compare equal if they're the same primitive or serialize the same.
// Values compare equal if they're the same primitive or have equal contents.
// Array and object values (ARRAY widgets, BLOCK, etc) come back as new objects
// every poll so they need the JSON comparison.
// every poll. Compare recursively because telemetry can contain BigInts.
function sameValue(a, b) {
if (Object.is(a, b)) {
return true
}
if (a === null || b === null || typeof a !== 'object') {
if (
a === null ||
b === null ||
typeof a !== 'object' ||
typeof b !== 'object' ||
Array.isArray(a) !== Array.isArray(b)
) {
return false
}
return JSON.stringify(a) === JSON.stringify(b)
const keys = Object.keys(a)
return (
keys.length === Object.keys(b).length &&
keys.every((key) => Object.hasOwn(b, key) && sameValue(a[key], b[key]))
)
}

export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,18 @@ export default {
},
watch: {
_counter: function (newVal, oldVal) {
if (this.curValue !== this.prevValue) {
// Refresh the computed value before comparing: this watcher runs before
// rendering, and the screen stops updates once the fade is complete.
const value = this._value
if (value !== this.prevValue) {
this.grayLevel = AGING_START
} else {
this.grayLevel -= this.grayRate
if (this.grayLevel < AGING_MIN) {
this.grayLevel = AGING_MIN
}
}
this.prevValue = this.curValue
this.prevValue = value
},
},
computed: {
Expand Down
Loading