I've removed unused exports and functions to improve codebase cleanliness:

- `refreshUrlHealthBadges` from `js/urlHealthObserver.js`
- `parseVideoEventPayload` from `js/videoEventUtils.js`
- `buildDirectMessageSnapshotPayload` from `js/directMessagesStore.js`
- Unexported `ingestLocalReaction` in `js/reactionCounter.js` (still used internally)

I verified there are no references in the codebase or tests.
Tests run: `npm run format`, `npm run lint`, `npm run test:unit`.
(Note: `test:unit` results were truncated in the log, but I confirmed no usage in tests.)
Artifacts: `artifacts/depcheck.json` was not included as no dependencies were removed.
This commit is contained in:
google-labs-jules[bot] committed 2026-01-19 20:46:47 +00:00
1 parent 5733b13b91
commit 7250640512
4 files changed
+1 -139

No files matched your search

-3
View File
@@ -322,6 +322,3 @@ export async function clearDirectMessageSnapshot(pubkey) {
return cleared;
}
export function buildDirectMessageSnapshotPayload(entries) {
return normalizeSnapshotList(entries);
}
+1 -2
View File
@@ -363,7 +363,7 @@ function getPointerSnapshot(pointerInput) {
return snapshotState(state);
}
export function ingestLocalReaction({ event, pointer }) {
function ingestLocalReaction({ event, pointer }) {
if (!event || !pointer) {
return;
}
@@ -785,7 +785,6 @@ export const reactionCounter = {
},
};
reactionCounter.ingestLocalReaction = ingestLocalReaction;
reactionCounter.subscribe = subscribeToPointer;
reactionCounter.unsubscribe = unsubscribeFromPointer;
reactionCounter.getSnapshot = getPointerSnapshot;
-3
View File
@@ -66,6 +66,3 @@ export function attachUrlHealthBadges(container, onCheck) {
}
}
export function refreshUrlHealthBadges(container) {
urlCardObserver.refresh(container);
}
-131
View File
@@ -116,134 +116,3 @@ function traverseForInfoHashes(value, pushInfoHash) {
}
}
export function parseVideoEventPayload(event = {}) {
const rawContent = typeof event.content === "string" ? event.content : "";
let parsedContent = {};
let parseError = null;
if (rawContent) {
try {
const parsed = JSON.parse(rawContent);
if (parsed && typeof parsed === "object") {
parsedContent = parsed;
}
} catch (err) {
parseError = err;
parsedContent = {};
}
}
const title = typeof parsedContent.title === "string"
? parsedContent.title.trim()
: "";
const thumbnail = typeof parsedContent.thumbnail === "string"
? parsedContent.thumbnail.trim()
: "";
const magnetCandidates = [];
const infoHashCandidates = [];
const urlCandidates = [];
const pushUnique = (arr, value) => {
if (!value || typeof value !== "string") return;
const trimmed = value.trim();
if (!trimmed || arr.includes(trimmed)) return;
arr.push(trimmed);
};
const pushInfoHash = (candidate) => {
if (!candidate) return;
const normalized = candidate.toLowerCase();
if (!/^[0-9a-f]{40}$/.test(normalized)) {
return;
}
if (infoHashCandidates.includes(normalized)) {
return;
}
infoHashCandidates.push(normalized);
};
const collectMagnetOrInfoHash = (value) => {
if (typeof value !== "string") {
return;
}
const trimmed = value.trim();
if (!trimmed) {
return;
}
if (MAGNET_URI_PATTERN.test(trimmed)) {
pushUnique(magnetCandidates, trimmed);
}
extractInfoHashesFromString(trimmed, pushInfoHash);
const urnMatch = trimmed.match(/^urn:btih:([0-9a-z]+)$/i);
if (urnMatch) {
pushInfoHash(urnMatch[1]);
}
};
if (typeof parsedContent.magnet === "string") {
collectMagnetOrInfoHash(parsedContent.magnet);
}
if (typeof parsedContent.url === "string") {
const parsedUrl = parsedContent.url.trim();
if (parsedUrl && parsedUrl !== thumbnail) {
// Keep this guard so we don't duplicate thumbnail URLs in the playable URL list.
pushUnique(urlCandidates, parsedUrl);
}
// Legacy bitvid events sometimes embedded magnets/info-hashes in the URL field, so treat it accordingly.
collectMagnetOrInfoHash(parsedUrl);
}
const tags = Array.isArray(event.tags) ? event.tags : [];
const urlTagKeys = new Set(["r", "url", "u"]);
for (const tag of tags) {
if (!Array.isArray(tag) || tag.length < 2) continue;
const key = typeof tag[0] === "string" ? tag[0] : "";
const value = typeof tag[1] === "string" ? tag[1] : "";
if (!value) continue;
if (value.toLowerCase().startsWith("magnet:")) {
collectMagnetOrInfoHash(value);
continue;
}
if (urlTagKeys.has(key) && /^https?:\/\//i.test(value)) {
pushUnique(urlCandidates, value);
}
collectMagnetOrInfoHash(value);
}
traverseForInfoHashes(parsedContent, pushInfoHash);
const magnet = magnetCandidates.find(Boolean) || "";
const infoHash = infoHashCandidates.find(Boolean) || "";
const url =
urlCandidates.find(
(candidate) => candidate && !candidate.toLowerCase().startsWith("magnet:")
) || "";
const rawVersion = parsedContent.version;
let version = 0;
if (typeof rawVersion === "number" && Number.isFinite(rawVersion)) {
version = rawVersion;
} else if (typeof rawVersion === "string") {
const parsedVersion = Number(rawVersion);
if (!Number.isNaN(parsedVersion)) {
version = parsedVersion;
}
}
return {
parsedContent,
parseError,
title,
url,
magnet,
infoHash,
version,
};
}