mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 21:02:28 +00:00
Refactor hardcoded feed identifiers to use constants
Introduced FEED_TYPES constants in js/constants.js and updated js/app/authSessionCoordinator.js, js/hashChangeHandler.js, js/viewManager.js, and js/app/feedCoordinator.js to use them. This improves maintainability and reduces the risk of typos in feed view names. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
22fcc97672
commit
a829cd95ca
6 files changed
+66
-46
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { devLogger as defaultDevLogger, userLogger as defaultUserLogger } from "./utils/logger.js";
|
||||
import { FEED_TYPES } from "./constants.js";
|
||||
|
||||
const LEGACY_DOCS_VIEWS = {
|
||||
about: "about",
|
||||
@@ -81,8 +82,8 @@ export function createHashChangeHandler({
|
||||
typeof window !== "undefined" && window.location && window.location.hash
|
||||
? window.location.hash
|
||||
: "";
|
||||
if (hash === "#kids") {
|
||||
window.location.hash = "#view=kids";
|
||||
if (hash === `#${FEED_TYPES.KIDS}`) {
|
||||
window.location.hash = `#view=${FEED_TYPES.KIDS}`;
|
||||
return;
|
||||
}
|
||||
const match = hash.match(/^#view=([^&]+)/);
|
||||
@@ -90,8 +91,8 @@ export function createHashChangeHandler({
|
||||
try {
|
||||
if (!match || !match[1]) {
|
||||
const defaultViewName = resolveIsLoggedIn()
|
||||
? "for-you"
|
||||
: "most-recent-videos";
|
||||
? FEED_TYPES.FOR_YOU
|
||||
: FEED_TYPES.RECENT;
|
||||
|
||||
if (defaultViewName === currentViewName) {
|
||||
return;
|
||||
@@ -119,7 +120,7 @@ export function createHashChangeHandler({
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof viewName === "string" && viewName.toLowerCase() === "history") {
|
||||
if (typeof viewName === "string" && viewName.toLowerCase() === FEED_TYPES.HISTORY) {
|
||||
}
|
||||
const viewUrl = `views/${viewName}.html`;
|
||||
|
||||
|
||||
Reference in new issue
Block a user