Commit Graph
27 Commits
Author SHA1 Message Date
thePR0M3TH3ANandClaude Opus 4.8 c562a326ae refactor(comments): extract comment-cache subsystem (7/10)
File-size decomposition (no behavior change). Move the localStorage comment-cache
methods (getCommentCacheKey, handleCommentCacheError, getCachedComments,
cacheComments, removeCommentCache, clearCommentCache, persistCommentCache,
serializeCommentsForCache) into js/services/commentThreadCache.js as functions
that take the service instance; the service keeps thin delegators so all call
sites are unchanged. Cache constants moved with them; FIVE_MINUTES_MS import
dropped from the service.

commentThreadService.js: 1296 -> 1100 lines (below its original 1122 baseline;
re-recorded to 1100).

Build + full unit suite green.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-19 16:31:13 -04:00
thePR0M3TH3ANandClaude Opus 4.8 f7cea24068 [comments] honor NIP-09 deletions in comment threads
Deleted comments previously persisted (no kind-5 handling; the thread cache
only merged-in). The thread service now processes NIP-09 deletion requests:

- A kind-5 event removes a target comment only when it is signed by that
  comment's own author (you cannot delete someone else's comment). The author
  match is the security boundary.
- Deletions are remembered per target, so a comment that arrives after its
  author's deletion (out-of-order relays) is suppressed on insert.
- On load, after fetching the thread, deletions for the loaded comment ids are
  fetched (kind 5, #e: ids) and applied before the thread is rendered, so the
  cache can't resurrect a deleted comment. Removal re-renders the thread.
- Replies to a removed comment become unreachable from the root and are hidden
  with their deleted parent.

`fetchDeletionEvents` is injectable; the default queries the relay pool. Live
deletions mid-session aren't subscribed yet (a kind-5 can't be scoped by the
video upfront) — deletions are honored on each thread open.

Tests: author-signed deletion removes the comment; a non-author deletion is
ignored; an out-of-order deletion suppresses the later comment. Both the
author-match and the suppress-on-insert guard are mutation-verified.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-18 13:55:03 -04:00
google-labs-jules[bot]andPR0M3TH3AN c47392aba6 Refactor numeric constants to centralized module
- Introduce `js/constants.js` with semantic time constants (e.g., `ONE_MINUTE_MS`, `STANDARD_TIMEOUT_MS`) and feature-specific TTLs.
- Export `KIND_MUTE_LIST` from `js/nostrEventSchemas.js` to standardize NIP-51 mute list kind usage.
- Refactor `js/state/cache.js`, `js/nostr/cachePolicies.js`, `js/channelProfile.js`, and various services to use centralized constants instead of hardcoded magic numbers.
- Update `js/nostr/relayConstants.js` to derive values from the shared time constants.
- Replace duplicate definitions of timeouts and retry delays across the codebase.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-11 03:27:26 +00:00
thePR0M3TH3AN 26a1f996f6 Start comment thread live subscription early 2026-01-06 22:25:01 -05:00
google-labs-jules[bot] 41ff140982 feat: enable dynamic comment loading and sorting 2026-01-07 03:03:46 +00:00
thePR0M3TH3AN 3c6e397984 Improve profile hydration retry diagnostics 2025-12-29 21:19:00 -05:00
thePR0M3TH3AN 735d67313c Add shared hex normalization for comment flows 2025-12-12 13:42:15 -05:00
thePR0M3TH3AN 624ab91c29 Add dev logging for improved comment cache fallback 2025-12-12 12:33:15 -05:00
thePR0M3TH3AN 7a56e7a691 Surface comment cache storage failures 2025-12-12 12:10:37 -05:00
thePR0M3TH3AN 2dd2be9345 Normalize comment thread event ids 2025-12-12 11:05:00 -05:00
thePR0M3TH3AN dacf5557bb Persist comment cache during teardown 2025-12-12 10:40:48 -05:00
thePR0M3TH3AN a6dcc44c12 Normalize comment cache keys 2025-12-12 10:29:33 -05:00
thePR0M3TH3AN 04e72a0b46 Propagate video root identifier from pointer metadata 2025-11-14 09:30:01 -05:00
thePR0M3TH3AN 8a111d8ee8 Handle lowercase root identifiers when fetching comments 2025-11-12 20:56:15 -05:00
thePR0M3TH3AN ec2da8af20 Allow comment threads without ensurePool 2025-11-12 20:37:51 -05:00
thePR0M3TH3AN 74bbe8e078 Add root identifier plumbing to modal comments 2025-11-12 20:31:43 -05:00
thePR0M3TH3AN ad6374de92 update 2025-11-07 16:19:50 -05:00
thePR0M3TH3AN f60aae282b update 2025-11-06 15:37:17 -05:00
thePR0M3TH3AN 6025f6e078 update 2025-11-05 14:49:33 -05:00
thePR0M3TH3AN 8258686f55 Preserve raw video author pubkeys for comment threads 2025-11-03 21:27:30 -05:00
thePR0M3TH3AN dc0b6a1f8c update 2025-11-03 21:05:20 -05:00
thePR0M3TH3AN 5d31366c79 Restore comment bootstrap and guard admin cache hydration 2025-11-03 20:19:45 -05:00
thePR0M3TH3AN c5eda532df feat: improve comment persistence on reload via union filters and caching
- Introduce FEATURE_IMPROVED_COMMENT_FETCHING flag (default: true in unstable)
- Enhance createVideoCommentFilters to include comprehensive union of legacy (#e/#a) and uppercase (#E/#A/#I/#K/#P) tags for NIP-22 compliance, reducing misses in mixed-relay propagation
- Add localStorage caching (5min TTL) in CommentThreadService.fetchThread for fast loads post-reload; includes getCachedComments, cacheComments, and clearCommentCache
- Force full-history re-fetch in VideoModalCommentController.load with retry logic if low count, plus background refresh after 1s
- Bootstrap cache warm-up for recent videos on bitvidApp init (tracks via localStorage recentVideos list)

Fixes: Comments posted not reloading in video modal (root cause: incomplete filters + no persistence)
Closes: #N/A (internal fix)
QA: Verified post → reload → modal open shows comments via cache/query; no regressions in threading/UI
Rollout: Gated by flag; rollback by setting false + clear localStorage (^comments: keys)
2025-11-03 15:46:12 -05:00
thePR0M3TH3AN 56b31f324e Improve comment metadata propagation 2025-10-29 15:24:10 -04:00
thePR0M3TH3AN a4e6db7151 Allow comments without definition address 2025-10-29 09:20:05 -04:00
thePR0M3TH3AN 92962f3b3d Refine comment thread service wiring 2025-10-24 15:54:25 -04:00
thePR0M3TH3AN 54d321d4c7 Add comment thread service with profile hydration and shared video pointer 2025-10-24 15:09:11 -04:00