mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-08 22:02:54 +00:00
Normalize video mode defaults for dev builds
This commit is contained in:
1 parent
eefa0a29fe
commit
7149494b4e
4 files changed
+138
-5
No files matched your search
@@ -560,7 +560,11 @@ class Application {
|
||||
editModalOverride: ui.editModal,
|
||||
container: modalContainer,
|
||||
services: {
|
||||
getMode: () => (isDevMode ? "dev" : "live"),
|
||||
getMode: ({ video } = {}) => {
|
||||
const candidate =
|
||||
typeof video?.mode === "string" ? video.mode.trim().toLowerCase() : "";
|
||||
return candidate === "dev" ? "dev" : "live";
|
||||
},
|
||||
sanitizers: {
|
||||
text: (value) => (typeof value === "string" ? value.trim() : ""),
|
||||
url: (value) => (typeof value === "string" ? value.trim() : ""),
|
||||
@@ -5001,6 +5005,9 @@ class Application {
|
||||
const description = normalizeString(legacyPayload?.description || "");
|
||||
const ws = normalizeString(legacyPayload?.ws || "");
|
||||
const xs = normalizeString(legacyPayload?.xs || "");
|
||||
const rawMode = normalizeString(legacyPayload?.mode || "");
|
||||
const normalizedMode =
|
||||
rawMode && rawMode.toLowerCase() === "dev" ? "dev" : "live";
|
||||
const enableComments = normalizeBooleanFlag(
|
||||
legacyPayload?.enableComments,
|
||||
true
|
||||
@@ -5017,7 +5024,7 @@ class Application {
|
||||
magnet,
|
||||
thumbnail,
|
||||
description,
|
||||
mode: isDevMode ? "dev" : "live",
|
||||
mode: normalizedMode,
|
||||
enableComments,
|
||||
isNsfw,
|
||||
isForKids,
|
||||
|
||||
@@ -19,7 +19,10 @@ export class EditModal {
|
||||
typeof setGlobalModalState === "function" ? setGlobalModalState : () => {};
|
||||
this.escapeHtml = typeof escapeHtml === "function" ? escapeHtml : (value) => `${value ?? ""}`;
|
||||
this.showError = typeof showError === "function" ? showError : () => {};
|
||||
this.getMode = typeof getMode === "function" ? getMode : () => "live";
|
||||
this.getMode =
|
||||
typeof getMode === "function"
|
||||
? getMode
|
||||
: () => (this.activeVideo?.mode ?? "live");
|
||||
this.eventTarget = eventTarget instanceof EventTarget ? eventTarget : new EventTarget();
|
||||
this.container = container || null;
|
||||
|
||||
@@ -312,6 +315,37 @@ export class EditModal {
|
||||
return { isNsfw, isForKids };
|
||||
}
|
||||
|
||||
normalizeMode(value) {
|
||||
if (typeof value === "string") {
|
||||
const normalized = value.trim().toLowerCase();
|
||||
if (normalized === "dev") {
|
||||
return "dev";
|
||||
}
|
||||
}
|
||||
return "live";
|
||||
}
|
||||
|
||||
resolveModeForSubmit() {
|
||||
let candidate = null;
|
||||
if (typeof this.getMode === "function") {
|
||||
try {
|
||||
candidate = this.getMode({ video: this.activeVideo });
|
||||
} catch (_error) {
|
||||
candidate = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof candidate === "string" && candidate.trim()) {
|
||||
return this.normalizeMode(candidate);
|
||||
}
|
||||
|
||||
if (this.activeVideo && typeof this.activeVideo.mode === "string") {
|
||||
return this.normalizeMode(this.activeVideo.mode);
|
||||
}
|
||||
|
||||
return "live";
|
||||
}
|
||||
|
||||
reset() {
|
||||
if (!this.root) {
|
||||
this.activeVideo = null;
|
||||
@@ -963,7 +997,7 @@ export class EditModal {
|
||||
url: finalUrl,
|
||||
thumbnail: finalThumbnail,
|
||||
description: finalDescription,
|
||||
mode: this.getMode(),
|
||||
mode: this.resolveModeForSubmit(),
|
||||
ws: finalWs,
|
||||
xs: finalXs,
|
||||
wsEdited: !shouldUseOriginalWs,
|
||||
|
||||
Reference in new issue
Block a user