[upload] Suggest one-tap hashtag chips from the user's past videos (#45)

The upload modal's Hashtags section now shows chips of the user's most-used past
hashtags ("Reuse a tag from your videos:"). Clicking one adds it to the NIP-71 't'
repeater; already-added chips dim + disable; the row is hidden for users with no
past tags.

- js/utils/hashtagSuggestions.js: pure rankHashtagsByFrequency(videos) — count =
  number of the user's videos using each tag, normalized (case + '#') and deduped
  per video, ranked by count then alphabetically. Reads video.nip71.hashtags, falls
  back to raw event 't' tags minus bitvid's fixed t=video marker.
- app.getUserHashtagSuggestions() sources the user's own videos via
  nostrService.getActiveVideosByAuthors([pubkey]) and ranks them (top 12), injected
  into the modal as getHashtagSuggestions.
- UploadModal renders the chips on open and wires clicks through the existing
  Nip71FormManager (addRepeaterEntry + setFieldValue, dedup via collectRepeaterValues).

Tests: tests/hashtag-suggestions.test.mjs (5 — per-video counting, normalization,
marker exclusion, tie-break + limit, empty input). Lint + build green.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
thePR0M3TH3ANandClaude Opus 4.8 committed 2026-07-01 20:59:56 -04:00
1 parent 6bdf28fb30
commit 3df398d7ad
7 files changed
+318 -5

No files matched your search

+6
View File
@@ -48,6 +48,12 @@ export function initUploadModal({
showSuccess,
getCurrentPubkey,
safeEncodeNpub,
// Frequency-ranked hashtags from the user's own past uploads → one-tap
// suggestion chips in the upload modal (TODO #45).
getHashtagSuggestions: (options) =>
typeof app?.getUserHashtagSuggestions === "function"
? app.getUserHashtagSuggestions(options)
: [],
eventTarget: events,
container,
onRequestStorageSettings: () => {