mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
- `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.
69 lines
1.8 KiB
JavaScript
69 lines
1.8 KiB
JavaScript
import { createCardObserver } from "./dom/cardObserver.js";
|
|
import { safeDecodeURIComponent } from "./utils/safeDecode.js";
|
|
import { userLogger } from "./utils/logger.js";
|
|
|
|
const ROOT_MARGIN = "0px";
|
|
const THRESHOLD = 0.25;
|
|
|
|
const urlCardObserver = createCardObserver({
|
|
rootMargin: ROOT_MARGIN,
|
|
threshold: THRESHOLD,
|
|
isCardVisible: (entry) => {
|
|
if (!entry) {
|
|
return false;
|
|
}
|
|
const isIntersecting = Boolean(entry.isIntersecting);
|
|
const ratio = typeof entry.intersectionRatio === "number" ? entry.intersectionRatio : 0;
|
|
return isIntersecting && ratio > 0;
|
|
},
|
|
createState: () => ({ onCheck: null }),
|
|
onCardVisible: ({ card, state }) => {
|
|
if (!state || typeof state.onCheck !== "function") {
|
|
return;
|
|
}
|
|
|
|
const badgeEl = card.querySelector("[data-url-health-state]");
|
|
if (!(badgeEl instanceof HTMLElement)) {
|
|
return;
|
|
}
|
|
|
|
const encodedUrl =
|
|
card.dataset.urlHealthUrl || badgeEl.dataset.urlHealthUrl || "";
|
|
const eventId =
|
|
card.dataset.urlHealthEventId || badgeEl.dataset.urlHealthEventId || "";
|
|
|
|
if (!encodedUrl || !eventId) {
|
|
return;
|
|
}
|
|
|
|
const currentState =
|
|
card.dataset.urlHealthState || badgeEl.dataset.urlHealthState;
|
|
if (currentState && currentState !== "checking") {
|
|
return;
|
|
}
|
|
|
|
const url = safeDecodeURIComponent(encodedUrl);
|
|
if (!url) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
state.onCheck({ card, badgeEl, url, eventId });
|
|
} catch (err) {
|
|
userLogger.warn("[urlHealthObserver] onCheck handler failed", err);
|
|
}
|
|
},
|
|
});
|
|
|
|
export function attachUrlHealthBadges(container, onCheck) {
|
|
if (!(container instanceof HTMLElement)) {
|
|
return;
|
|
}
|
|
|
|
const state = urlCardObserver.observe(container);
|
|
if (state && typeof onCheck === "function") {
|
|
state.onCheck = onCheck;
|
|
}
|
|
}
|
|
|