mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-07 21:32:51 +00:00
Stabilize moderation fixture readiness
This commit is contained in:
1 parent
5c9dbf7aff
commit
dcf3221f00
2 files changed
+40
No files matched your search
@@ -60,6 +60,7 @@
|
||||
import moderationService from "/js/services/moderationService.js";
|
||||
|
||||
const STORAGE_KEY = "bitvid:moderation:fixture-overrides";
|
||||
const READY_FLAG = "__moderationFixturesReady__";
|
||||
// These fixtures mirror the upstream defaults in config/instance-config.js.
|
||||
// Update the numbers alongside DEFAULT_BLUR_THRESHOLD, DEFAULT_AUTOPLAY_BLOCK_THRESHOLD,
|
||||
// DEFAULT_TRUSTED_MUTE_HIDE_THRESHOLD, and DEFAULT_TRUSTED_SPAM_HIDE_THRESHOLD when they change.
|
||||
@@ -282,6 +283,7 @@
|
||||
}
|
||||
|
||||
window.__MODERATION_FIXTURE_STORAGE_KEY__ = STORAGE_KEY;
|
||||
window[READY_FLAG] = false;
|
||||
|
||||
function loadOverrides() {
|
||||
try {
|
||||
@@ -593,12 +595,24 @@
|
||||
card.onModerationOverride = () => {
|
||||
overrides = setOverride(overrides, video.id, { showAnyway: true });
|
||||
refreshModeration();
|
||||
try {
|
||||
document.dispatchEvent(
|
||||
new CustomEvent("video:moderation-override", {
|
||||
detail: { video }
|
||||
})
|
||||
);
|
||||
} catch {
|
||||
/* ignore fixture event errors */
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
const root = card.getRoot();
|
||||
root.dataset.testId = fixture.key;
|
||||
if (fixture.enableOverride) {
|
||||
root.dataset.moderationOverrideAvailable = "true";
|
||||
}
|
||||
return { card, root, refreshModeration };
|
||||
}
|
||||
|
||||
@@ -688,6 +702,7 @@
|
||||
}
|
||||
|
||||
renderFixtures();
|
||||
window[READY_FLAG] = true;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user