mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-05 20:32:27 +00:00
[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:
1 parent
a090864bc2
commit
2aae4094e7
11 files changed
+35
-20
No files matched your search
@@ -7,6 +7,7 @@ import {
|
||||
import { sanitizeRelayList } from "../nostr/nip46Client.js";
|
||||
import { publishEventToRelay } from "../nostrPublish.js";
|
||||
import logger from "../utils/logger.js";
|
||||
import { SHORT_TIMEOUT_MS } from "../constants.js";
|
||||
|
||||
const DEFAULT_BACKOFF = {
|
||||
baseMs: 1000,
|
||||
@@ -15,7 +16,7 @@ const DEFAULT_BACKOFF = {
|
||||
};
|
||||
|
||||
const MAX_SEEN_EVENT_IDS = 5000;
|
||||
const DM_RELAY_LIST_TIMEOUT_MS = 5000;
|
||||
const DM_RELAY_LIST_TIMEOUT_MS = SHORT_TIMEOUT_MS;
|
||||
export const DM_RELAY_WARNING_FALLBACK = "dm-relays-fallback";
|
||||
|
||||
function normalizeRelayList(relays) {
|
||||
|
||||
@@ -31,6 +31,7 @@ import {
|
||||
setLastSuccessfulScheme,
|
||||
} from "../nostr/decryptionSchemeCache.js";
|
||||
import { HEX64_REGEX } from "../utils/hex.js";
|
||||
import { SHORT_TIMEOUT_MS, NETWORK_RETRY_DELAY_MS } from "../constants.js";
|
||||
|
||||
const LOG_PREFIX = "[HashtagPreferences]";
|
||||
const HASHTAG_IDENTIFIER = "bitvid:tag-preferences";
|
||||
@@ -43,7 +44,7 @@ const DEFAULT_VERSION = 1;
|
||||
const DECRYPT_TIMEOUT_MS = 6000;
|
||||
// PERF: Reduced from 3s to 1.5s — extensions that already granted permission
|
||||
// should recover near-instantly. Shorter delay speeds up the login path.
|
||||
const DECRYPT_RETRY_DELAY_MS = 1500;
|
||||
const DECRYPT_RETRY_DELAY_MS = NETWORK_RETRY_DELAY_MS;
|
||||
|
||||
class TinyEventEmitter {
|
||||
constructor() {
|
||||
@@ -1052,7 +1053,7 @@ class HashtagPreferencesService {
|
||||
// gate guarantees the extension is ready before decryption starts, so
|
||||
// decrypt calls should complete within 1-2s. 5s accommodates slow
|
||||
// extensions while still failing fast for scheme fallback.
|
||||
const nip07DecryptTimeoutMs = allowPermissionPrompt ? 12000 : 5000;
|
||||
const nip07DecryptTimeoutMs = allowPermissionPrompt ? 12000 : SHORT_TIMEOUT_MS;
|
||||
const signerDecryptOptions = {
|
||||
priority: NIP07_PRIORITY.NORMAL,
|
||||
timeoutMs: nip07DecryptTimeoutMs,
|
||||
|
||||
@@ -8,6 +8,7 @@ import { accessControl } from "../accessControl.js";
|
||||
import { userBlocks, USER_BLOCK_EVENTS } from "../userBlocks.js";
|
||||
import { buildReportEvent, KIND_MUTE_LIST } from "../nostrEventSchemas.js";
|
||||
import logger from "../utils/logger.js";
|
||||
import { DEBOUNCE_DELAY_MS } from "../constants.js";
|
||||
|
||||
/**
|
||||
* Trust threshold for disabling autoplay on reported videos.
|
||||
@@ -1135,7 +1136,7 @@ export class ModerationService {
|
||||
this.refreshTrustedMuteSubscriptions().catch((error) => {
|
||||
this.log("[moderationService] refreshTrustedMuteSubscriptions failed", error);
|
||||
});
|
||||
}, 2000);
|
||||
}, DEBOUNCE_DELAY_MS);
|
||||
}
|
||||
|
||||
async refreshTrustedMuteSubscriptions() {
|
||||
|
||||
Reference in new issue
Block a user