[constants] refactor duplicate numeric constants

- Add `UI_FEEDBACK_DELAY_MS`, `DEBOUNCE_DELAY_MS`, and `NETWORK_RETRY_DELAY_MS` to `js/constants.js`.
- Replace magic numbers (5000, 2000, 1500) with semantic constants in:
  - `js/ui/notificationController.js`
  - `js/ui/profileModal/ProfileDirectMessageActions.js`
  - `js/ui/urlHealthController.js`
  - `js/app/uiCoordinator.js`
  - `js/ui/components/VideoModal.js`
  - `js/ui/components/UploadModal.js`
  - `js/services/dmNostrService.js`
  - `js/services/hashtagPreferencesService.js`
  - `js/app/feedCoordinator.js`
  - `js/services/moderationService.js`

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-02-12 03:43:03 +00:00
1 parent a090864bc2
commit 2aae4094e7
11 files changed
+35 -20

No files matched your search

+2 -2
View File
@@ -9,7 +9,7 @@
* Methods use `this` which is bound to the Application instance.
*/
import { FEED_TYPES, STANDARD_TIMEOUT_MS, MEDIUM_TIMEOUT_MS } from "../constants.js";
import { FEED_TYPES, STANDARD_TIMEOUT_MS, MEDIUM_TIMEOUT_MS, DEBOUNCE_DELAY_MS } from "../constants.js";
/**
* @param {object} deps - Injected dependencies.
@@ -1056,7 +1056,7 @@ export function createFeedCoordinator(deps) {
}
const now = Date.now();
if (this.lastLoadVideosTime && (now - this.lastLoadVideosTime < 2000) && !forceFetch) {
if (this.lastLoadVideosTime && (now - this.lastLoadVideosTime < DEBOUNCE_DELAY_MS) && !forceFetch) {
devLogger.log("Skipping redundant loadVideos request (cooldown).");
return Promise.resolve();
}
+4 -2
View File
@@ -8,6 +8,8 @@
*
* Methods use `this` which is bound to the Application instance.
*/
import { SHORT_TIMEOUT_MS, DEBOUNCE_DELAY_MS } from "../constants.js";
export function createUiCoordinator(deps) {
const {
devLogger,
@@ -286,7 +288,7 @@ export function createUiCoordinator(deps) {
if (
this.lastExperimentalWarningKey === normalizedProvider &&
typeof this.lastExperimentalWarningAt === "number" &&
now - this.lastExperimentalWarningAt < 2000
now - this.lastExperimentalWarningAt < DEBOUNCE_DELAY_MS
) {
return;
}
@@ -301,7 +303,7 @@ export function createUiCoordinator(deps) {
this.showStatus(
`${providerLabel} logins are still in development and may not work well yet. We recommend using a NIP-07 browser extension for the most reliable experience.`,
{ showSpinner: false, autoHideMs: 5000 },
{ showSpinner: false, autoHideMs: SHORT_TIMEOUT_MS },
);
}
};