Skip to content

Commit 6e6532f

Browse files
CopilotPDowney
andauthored
refactor: define LEGACY_KEYFRAMES_RULE_TYPE constant at module level and extract millisecondsToSeconds helper
Agent-Logs-Url: https://github.com/EngineScript/EngineScript/sessions/8e7ceb0f-90ab-40c3-99dd-7bca95e3085a Co-authored-by: PDowney <[email protected]>
1 parent e7f81b2 commit 6e6532f

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ Changes are organized by date, with the most recent changes listed first.
66

77
## 2026-04-11
88

9+
### 🔧 EXTERNAL SERVICES CODE QUALITY IMPROVEMENTS
10+
11+
- Extracted `LEGACY_KEYFRAMES_RULE_TYPE = 7` to a named module-level constant in `external-services.js`, replacing the magic number defined inside `hasAnimationKeyframes()` to improve maintainability and make the value reusable.
12+
- Added `millisecondsToSeconds()` helper method to `ExternalServicesManager` in `external-services.js`, replacing the inline `/ 1000` conversion in `scheduleNotificationRemoval()` to eliminate duplication and clarify intent.
13+
14+
## 2026-04-11
15+
916
### 🔧 VHOST IMPORT BUG FIXES & IMPROVEMENTS
1017

1118
- Updated the single-zip database file detection in `scripts/functions/vhost/vhost-import.sh` to search for both `*.sql` and `*.sql.gz` patterns, so compressed database dumps are correctly found and imported instead of failing silently.

config/var/www/admin/control-panel/external-services/external-services.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ const CATEGORY_ORDER = [
1818
'Security'
1919
];
2020

21+
// Standard CSSOM numeric value for KEYFRAMES_RULE, used when CSSRule.KEYFRAMES_RULE is unavailable (legacy browsers).
22+
const LEGACY_KEYFRAMES_RULE_TYPE = 7;
23+
2124
const ERROR_LOADING_EXTERNAL_SERVICES_MESSAGE = "Failed to fetch external service status. Check your internet connection and refresh the page. If the problem continues, check the browser console for details or contact your administrator.";
2225

2326
const SETTINGS_INSTRUCTION_TEXT = 'Toggle services to show/hide on the dashboard. Drag service cards to reorder them, or use the keyboard: press Enter to activate reorder mode and use arrow keys to move cards. Click "Save Changes" to apply. Services are organized by category.';
@@ -1767,8 +1770,6 @@ export class ExternalServicesManager {
17671770
*/
17681771
hasAnimationKeyframes(animationName) {
17691772
const styleSheets = Array.from(document.styleSheets || []);
1770-
// Standard CSSOM numeric value for KEYFRAMES_RULE, used when CSSRule.KEYFRAMES_RULE is unavailable (legacy browsers).
1771-
const LEGACY_KEYFRAMES_RULE_TYPE = 7;
17721773
const keyframesType = typeof CSSRule !== 'undefined' ? CSSRule.KEYFRAMES_RULE : LEGACY_KEYFRAMES_RULE_TYPE;
17731774

17741775
for (const styleSheet of styleSheets) {
@@ -1785,6 +1786,15 @@ export class ExternalServicesManager {
17851786
return false;
17861787
}
17871788

1789+
/**
1790+
* Convert milliseconds to seconds for CSS time values.
1791+
* @param {number} durationMs
1792+
* @returns {number}
1793+
*/
1794+
millisecondsToSeconds(durationMs) {
1795+
return durationMs / 1000;
1796+
}
1797+
17881798
/**
17891799
* Schedule notification slide-out and removal.
17901800
* Uses two-stage timing: display duration first, then animation duration before DOM removal.
@@ -1794,7 +1804,7 @@ export class ExternalServicesManager {
17941804
scheduleNotificationRemoval(notification) {
17951805
setTimeout(() => {
17961806
if (this.hasAnimationKeyframes(this.notificationSlideOutAnimationName)) {
1797-
notification.style.animation = `${this.notificationSlideOutAnimationName} ${this.notificationAnimationDurationMs / 1000}s ease`;
1807+
notification.style.animation = `${this.notificationSlideOutAnimationName} ${this.millisecondsToSeconds(this.notificationAnimationDurationMs)}s ease`;
17981808
}
17991809
setTimeout(() => notification.remove(), this.notificationAnimationDurationMs);
18001810
}, this.notificationDurationMs);

0 commit comments

Comments
 (0)