- Extracted payload construction logic from `revertVideo` in `js/nostr/client.js` to `buildRevertVideoPayload` in `js/nostr/publishHelpers.js`.
- Moved `resolveStoragePointerValue` from `js/nostr/client.js` to `js/utils/storagePointer.js` to fix circular dependencies and improve code organization.
- Updated imports in `js/nostr/client.js` and `js/nostr/publishHelpers.js`.
- Verified with existing tests.
Co-authored-by: PR0M3TH3AN <[email protected]>
The NIP-07 login flow was extremely slow because list decryption (blocks,
subscriptions, hashtag preferences) started before the signer was ready.
On page refresh, all three services failed with "permission-required" and
scheduled 3-second retry delays, adding 6-10 seconds to every login.
Key fixes:
- List loading now waits for the permission pre-grant to complete before
attempting decryption, ensuring the signer is available on first try
- Extension wait timeout increased from 3s to 5s for slower extensions
- Decrypt timeouts reduced from 20s to 10s (signer is guaranteed ready)
- Auto-login now forwards authType/providerId from saved profiles
- Storage tab unlock falls back to ensureActiveSignerForPubkey when the
global signer is not yet registered
- Watch history feed registration adds defensive re-registration and
try/catch fallback to prevent "Feed not registered" errors
- Decryption scheme cache TTL extended from 10 minutes to 2 hours
- ensureExtensionPermissions waits for extension injection when there
are outstanding permissions to request (was returning immediately)
https://claude.ai/code/session_01T4wwPu7m5qp1Nxx3H2v57j
Removed a duplicate/malformed code block in `js/app.js` that was causing `SyntaxError: Unexpected token '.'` during module loading. This error was breaking tests in `tests/app/channel-profile-moderation.test.mjs` and others.
Also restored `_initNostr` and `_initSessionActor` methods which were partially clobbered or malformed in the file structure.
Verified by running the affected unit tests locally.
Co-authored-by: PR0M3TH3AN <[email protected]>
The `feedCoordinator` logic assumes `this.refreshFeed` exists on the Application instance (because methods are bound via `bindCoordinator`). However, `Application` previously only implemented `refreshRecentFeed`, `refreshForYouFeed`, etc., but not the generic `refreshFeed`.
This caused a `TypeError: this.refreshFeed is not a function` when `loadFeedVideos` (which calls `refreshFeed`) was invoked.
This commit adds `async refreshFeed(...args)` to `Application` in `js/app.js`, delegating to `this._feed.refreshFeed(...args)`.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Removed orphaned code block in `js/app.js` that caused syntax errors during module loading.
- Updated `tests/helpers/moderation-test-helpers.mjs` to implement `resumePendingModeratedPlayback` and decoration logic in `MockApplication`, fixing `tests/app/moderation-overrides.test.mjs` and `tests/app/moderation-settings-refresh.test.mjs` failures.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Restored missing `_initNostr` method in `js/app.js` which was causing `SyntaxError: Unexpected token '.'` and `nostrClient.init is not a function` errors.
- Removed dangling code block that was causing the syntax error (orphaned `accessControl.refresh()...` block).
- This fixes unit tests (e.g. `tests/app/channel-profile-moderation.test.mjs`) and application initialization.
Co-authored-by: PR0M3TH3AN <[email protected]>
Removes a malformed code block that was causing an "Unexpected token '.'" syntax error and restores the `_initNostr` method which correctly initializes the Nostr client.
Fixes: #1083 (SyntaxError in app.js)
Co-authored-by: PR0M3TH3AN <[email protected]>
- Replaced `NostrClient.rawEvents` standard Map with `EventsMap`
- Implemented `EventsMap` to maintain an author-based index
- Updated `js/channelProfile.js` to use `getEventsByAuthor` for efficient lookup
- Added unit tests for `EventsMap`
- Added benchmark script verifying ~15x performance improvement (637ms -> 41ms for 1M events)
Co-authored-by: PR0M3TH3AN <[email protected]>
- Extracted logic into `_init*` private helper methods.
- Preserved execution order and async behavior.
- Cleaned up the main `init` method to act as an orchestrator.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Unify `refreshForYouFeed`, `refreshKidsFeed`, `refreshExploreFeed`, and `refreshRecentFeed` into `refreshFeed(feedType, options)`.
- Update `js/app/feedCoordinator.js` to implement `refreshFeed` and use it in `loadFeedVideos`.
- Update `js/app.js` to delegate specific methods to `refreshFeed`.
- Add `FEED_TYPES` import to `js/app.js`.
- Update `tests/app/feedCoordinator.test.mjs` to match the refactoring.
Co-authored-by: PR0M3TH3AN <[email protected]>
Removed the legacy support for version 1 moderation overrides in `js/state/cache.js`. This includes removing the `LEGACY_MODERATION_OVERRIDE_STORAGE_KEY`, the migration logic in `loadModerationOverridesFromStorage`, and the cleanup logic in `persistModerationOverridesToStorage`.
Updated `tests/state/cache.test.mjs` to include tests verifying that legacy overrides are ignored and not migrated.
Co-authored-by: PR0M3TH3AN <[email protected]>
Moved logging helpers (`summarizeHexForLog`, `summarizeSecretForLog`, etc.) from `js/nostr/nip46Client.js` to `js/nostr/nip46LoggingUtils.js` to reduce clutter and improve reuse. Updated `js/nostr/client.js` and `js/services/authProviders/nip46.js` to import from the new module, removing duplicate definitions in the latter. Verified with existing tests.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Merged `handleChromeTorrent` and `handleFirefoxTorrent` into `handleTorrentStream` with a `context` parameter.
- Preserved browser-specific logic (CORS workaround for Chrome, highWaterMark for Firefox).
- Added `tests/webtorrent-handlers.test.mjs` to cover the refactored logic.
Co-authored-by: PR0M3TH3AN <[email protected]>
Extracted parameter normalization, context resolution, and tag building into dedicated helper functions (`normalizeCommentInputs`, `resolveCommentContext`, `buildCommentTags`) to improve readability and maintainability of `buildCommentEvent`. This simplifies the main function logic and makes it easier to test individual components in the future if exported.
No functional changes intended. Verified with existing unit and integration tests.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Adds a default connection timeout of 5000ms to `RelayHealthService.checkRelay`.
- Adds comprehensive tests for `RelayHealthService` covering:
- Connection timeouts (mocked).
- Failure thresholds for user logging.
- Logging cooldowns (mocked time).
- Relay `disconnect` and `error` event handling.
- `nostrClient.markRelayUnreachable` integration.
- Refactors tests to use manual mocking for `setTimeout` and `Date.now` for stability.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Extract `prioritizeEntries` logic to `js/gridHealthLogic.js` for testability
- Add comprehensive unit tests in `tests/grid-health.test.mjs`
- Improve `getIntersectionRect` to robustly handle invalid rects
- Ensure 0x0 rects are filtered out explicitly
Co-authored-by: PR0M3TH3AN <[email protected]>
Exports `collectCandidateStrings` and `shouldSuppressWarning` from `js/nostr/maxListenerDiagnostics.js` to enable unit testing.
Adds `tests/nostr/maxListenerDiagnostics.test.mjs` to test the warning suppression logic and verify the `process.emitWarning` patch side effect.
Fixes missing `jsdom` dependency issue by running `npm install`.
Co-authored-by: PR0M3TH3AN <[email protected]>
Removes commented-out `await Promise.all` and refactors the associated
`accessControlPromise` and `adminPanePromise` variables in `js/app.js`.
The promises were only assigned for use in the commented-out line.
This change:
- Converts `accessControl.refresh()` to a direct expression statement.
- Simplifies `adminPanePromise` logic into a direct `if` block, removing
the unnecessary `else { Promise.resolve(null) }` branch.
- Preserves the existing fire-and-forget behavior for these initialization tasks.
Co-authored-by: PR0M3TH3AN <[email protected]>
The `loadFeedVideos` method was missing from the `Application` class in `js/app.js`, but was being called by `loadVideos` inside the feed coordinator (which is bound to the application instance). This caused a `TypeError: this.loadFeedVideos is not a function` at runtime.
This change adds the missing delegation method to `Application` in `js/app.js`, forwarding the call to `this._feed.loadFeedVideos`.
Co-authored-by: PR0M3TH3AN <[email protected]>
Replaced the legacy "interests" string literal with NOTE_TYPES.HASHTAG_PREFERENCES
in profileCache calls to unify key usage. Updated migration logic and comments.
Verified that the underlying storage key remains consistent for backward compatibility.
Co-authored-by: PR0M3TH3AN <[email protected]>
Removes the custom `bech32Polymod` and related Bech32 decoding functions from `js/nostr/nip46Client.js` in favor of using `nostr-tools` library implementation via `nip19.decode`. This reduces code duplication and relies on the standard library for decoding npubs.
Breaking Changes:
- None. `decodeNpubToHex` now strictly requires `nostr-tools` to be available, which is consistent with the rest of the file's dependencies.
Tests:
- Verified with targeted unit tests (`tests/nostr/nip46Client.test.js`).
- Verified with a reproduction script (`tests/repro_issue.mjs`) ensuring `decodeNpubToHex` correctly decodes valid npubs and handles invalid inputs.
Co-authored-by: PR0M3TH3AN <[email protected]>
Removes the call to `app.persistWatchHistoryMetadataForVideo` in `renderChannelVideosFromList` within `js/channelProfile.js`. This function was identified as a no-op (delegating to a deprecated empty method), adding unnecessary overhead to the rendering loop.
Benchmark results (100M iterations):
- With call: ~1278ms
- Without call: ~88ms
- Improvement: ~14x speedup in the tight loop simulation.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Introduce `loadFeedVideos(feedType, forceFetch)` in `js/app/feedCoordinator.js` to consolidate video loading logic.
- Update `loadForYouVideos`, `loadKidsVideos`, `loadExploreVideos`, and `loadVideos` to use the shared method.
- Parameterize feed-specific configuration (telemetry context, tags, loading messages, relay health checks) based on feed type.
- Add `tests/app/feedCoordinator.test.mjs` to verify the new logic.
Signed-off-by: Jules <[email protected]>
Co-authored-by: PR0M3TH3AN <[email protected]>