mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 16:02:26 +00:00
KNOWN_BUGS #1: logged out, the video grid stayed empty after dismissing the disclaimer until a manual page refresh. Reproduced deterministically with scripts/perf/disclaimer-grid.mjs (fresh context, real relays) once it actually waits for and dismisses the disclaimer: post-dismiss card timeline was 0,0,0,… and only a reload yielded 132 cards. Root cause: bootstrapInterface (js/index.js) opens the disclaimer — which makes the background inert via staticModalAccessibility — and THEN awaits handleHashChange(), which loads the feed view and renders into that inert/hidden background, so the initial grid mount/render is dropped. Dismissing the disclaimer never re-triggered a render. Fix: disclaimer.js hide() now dispatches a `bitvid:disclaimer-dismissed` event; index.js listens once and calls application.loadVideos(true) so the feed re-renders into the now-interactive background. Only fires when a shown disclaimer is dismissed, so returning visitors (who never see it) get no redundant reload. Harness after fix: post-dismiss timeline 132,132,… immediately. Full build + unit suite green. Co-Authored-By: Claude Opus 4.8 <[email protected]>
72 lines
2.0 KiB
JavaScript
72 lines
2.0 KiB
JavaScript
// js/disclaimer.js
|
|
|
|
import {
|
|
prepareStaticModal,
|
|
openStaticModal,
|
|
closeStaticModal,
|
|
} from "./ui/components/staticModalAccessibility.js";
|
|
|
|
class DisclaimerModal {
|
|
constructor() {
|
|
this.modal = null;
|
|
this.acceptButton = null;
|
|
this.acceptHandler = null;
|
|
}
|
|
|
|
init() {
|
|
this.modal = document.getElementById("disclaimerModal");
|
|
if (this.modal) {
|
|
prepareStaticModal({ root: this.modal });
|
|
}
|
|
const nextAcceptButton = document.getElementById("acceptDisclaimer");
|
|
|
|
if (!this.acceptHandler) {
|
|
this.acceptHandler = () => {
|
|
this.hide();
|
|
};
|
|
}
|
|
|
|
if (this.acceptButton && this.acceptHandler) {
|
|
this.acceptButton.removeEventListener("click", this.acceptHandler);
|
|
}
|
|
|
|
this.acceptButton = nextAcceptButton || null;
|
|
|
|
if (this.acceptButton && this.acceptHandler) {
|
|
this.acceptButton.addEventListener("click", this.acceptHandler);
|
|
}
|
|
}
|
|
|
|
hide() {
|
|
if (this.modal && !closeStaticModal(this.modal)) {
|
|
this.modal.classList.add("hidden");
|
|
}
|
|
localStorage.setItem("hasSeenDisclaimer", "true");
|
|
// The feed view mounts/renders DURING boot while this disclaimer is open and
|
|
// the background is inert/hidden, so the initial grid render is dropped and
|
|
// never recovers without a manual refresh (KNOWN_BUGS #1). Now that the
|
|
// background is interactive again, tell the app to (re)render the feed.
|
|
try {
|
|
document.dispatchEvent(new CustomEvent("bitvid:disclaimer-dismissed"));
|
|
} catch (_) {
|
|
// CustomEvent unavailable (non-browser) — nothing to notify.
|
|
}
|
|
}
|
|
|
|
show() {
|
|
// In case the modal hasn't been initialized yet.
|
|
if (!this.modal) {
|
|
this.init();
|
|
}
|
|
if (!localStorage.getItem("hasSeenDisclaimer") && this.modal) {
|
|
if (!openStaticModal(this.modal)) {
|
|
this.modal.classList.remove("hidden");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Create and export a default instance.
|
|
const disclaimerModal = new DisclaimerModal();
|
|
export default disclaimerModal;
|