mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
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 <[email protected]>
This commit is contained in:
1 parent
9913e484ab
commit
d18b3c4838
1 file changed
+2
-12
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user