Skip to content

Commit dca23aa

Browse files
ozyxakhenry
authored andcommitted
fix: suppress deprecation warnings to once per unique args (#6875)
1 parent 44415b3 commit dca23aa

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/api/time/TimeContext.js

+12
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class TimeContext extends EventEmitter {
4242
this.activeClock = undefined;
4343
this.offsets = undefined;
4444
this.mode = undefined;
45+
this.warnCounts = {};
4546

4647
this.tick = this.tick.bind(this);
4748
}
@@ -648,6 +649,17 @@ class TimeContext extends EventEmitter {
648649
}
649650

650651
#warnMethodDeprecated(method, newMethod) {
652+
const MAX_CALLS = 1; // Only warn once per unique method and newMethod combination
653+
654+
const key = `${method}.${newMethod}`;
655+
const currentWarnCount = this.warnCounts[key] || 0;
656+
657+
if (currentWarnCount >= MAX_CALLS) {
658+
return; // Don't warn if already warned once
659+
}
660+
661+
this.warnCounts[key] = currentWarnCount + 1;
662+
651663
let message = `[DEPRECATION WARNING]: The ${method} API method is deprecated and will be removed in a future version of Open MCT.`;
652664

653665
if (newMethod) {

0 commit comments

Comments
 (0)