Refactor power subscription handling in NSPanelTs

Refactor subscribePowerSubscriptions to use a subscription key for better management of subscriptions.
This commit is contained in:
Armilar
2026-02-17 23:43:00 +01:00
committed by GitHub
parent 41f4062ab8
commit 330fa9bfd4

View File

@@ -8850,7 +8850,11 @@ function unsubscribePowerSubscriptions (): void {
* @returns {void}
*/
function subscribePowerSubscriptions (id: string): void {
on({id: id + '.ACTUAL', change: 'ne'}, async function () {
const subscriptionKey = 'power_' + id + '.ACTUAL';
if (subscriptions.hasOwnProperty(subscriptionKey)) {
return;
}
subscriptions[subscriptionKey] = on({id: id + '.ACTUAL', change: 'ne'}, async function () {
(function () {
if (timeoutPower) {
clearTimeout(timeoutPower);
@@ -8863,7 +8867,6 @@ function subscribePowerSubscriptions (id: string): void {
});
}
/**
* @function GeneratePowerPage
* @description Generates a page with power state and energy usage information.