From d18b3c48381e045bf1637da14904c8d849633337 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 26 Feb 2026 17:31:04 +0000 Subject: [PATCH] Refactor extractDTagValue in js/app.js to use getDTagValueFromTags This commit replaces the duplicated d-tag extraction logic in `extractDTagValue` method of `js/app.js` with the standard utility function `getDTagValueFromTags` from `js/nostr/nip71.js`. This improves code reuse and maintainability. The fallback logic for `extractDTagValue` now delegates to `getDTagValueFromTags` if `similarContentController` is not present, ensuring consistent behavior. Verified with unit tests and linting. Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- js/app.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/js/app.js b/js/app.js index ac71b4b6..c4a54347 100644 --- a/js/app.js +++ b/js/app.js @@ -2,6 +2,7 @@ import { nostrClient } from "./nostrClientFacade.js"; import { recordVideoView } from "./nostrViewEventsFacade.js"; +import { getDTagValueFromTags } from "./nostr/nip71.js"; import { torrentClient } from "./webtorrent.js"; import { emit } from "./embedDiagnostics.js"; import { @@ -1370,18 +1371,7 @@ class Application { return this.similarContentController.extractDTagValue(tags); } // Fallback if controller not initialized (though it should be) - if (!Array.isArray(tags)) { - return ""; - } - for (const tag of tags) { - if (!Array.isArray(tag) || tag.length < 2) { - continue; - } - if (tag[0] === "d" && typeof tag[1] === "string") { - return tag[1]; - } - } - return ""; + return getDTagValueFromTags(tags); } deriveVideoPointerInfo(video) {