Files
bitvid/js/ui/videoListViewController.js
T
google-labs-jules[bot] 5c65c44db3 feat: Remove hashtag pills from For You page
- Updated `For You` page to rely on feed engine filtering for tag preferences.
- Removed the `recentVideoTags` HTML element from `views/for-you.html`.
- Updated `js/app.js` and `js/ui/videoListViewController.js` to optionally skip finding the `recentVideoTags` element.
- Updated `loadForYouVideos` in `js/app.js` to explicitly skip `recentVideoTags`.
- Confirmed feed logic via `tests/feed-engine/tag-preference-filter.test.mjs`.
- Verified UI changes via Playwright.
2026-01-19 02:33:17 +00:00

99 lines
2.6 KiB
JavaScript

import { devLogger as defaultLogger } from "../utils/logger.js";
export default class VideoListViewController {
constructor({ getSidebarLoadingMarkup, environment = {}, logger } = {}) {
this.getSidebarLoadingMarkup =
typeof getSidebarLoadingMarkup === "function"
? getSidebarLoadingMarkup
: () => "";
this.document = environment.document || (typeof document !== "undefined" ? document : null);
this.logger = logger || defaultLogger;
}
isElement(value) {
return (
typeof HTMLElement !== "undefined" && value instanceof HTMLElement
);
}
mount({ container = null, view, currentVideoList = null, includeTags = true } = {}) {
if (!view) {
return { videoList: currentVideoList || null, popularTags: null };
}
const target = container || this.getElementById("videoList");
let popularTags = null;
if (includeTags) {
popularTags = this.getElementById("recentVideoTags");
}
if (typeof view.setPopularTagsContainer === "function") {
view.setPopularTagsContainer(popularTags || null);
}
view.mount(target || null);
return {
videoList: target || null,
popularTags: popularTags || null,
};
}
reinitialize({
view,
reason,
postLoginResult,
currentVideoList = null,
} = {}) {
if (!view) {
return {
videoList: currentVideoList || null,
popularTags: null,
};
}
const container =
this.isElement(currentVideoList) && currentVideoList
? currentVideoList
: this.getElementById("videoList");
try {
view.destroy();
} catch (error) {
if (this.logger?.warn) {
this.logger.warn(
"[VideoListViewController] Failed to destroy VideoListView during reinitialization:",
error,
);
}
}
const messageContext =
reason === "login" && postLoginResult?.blocksLoaded !== false
? "Applying your filters…"
: "Refreshing videos…";
const tagsRoot = this.getElementById("recentVideoTags");
if (typeof view.setPopularTagsContainer === "function") {
view.setPopularTagsContainer(this.isElement(tagsRoot) ? tagsRoot : null);
}
if (this.isElement(container)) {
container.innerHTML = this.getSidebarLoadingMarkup(messageContext);
}
return {
videoList: this.isElement(container) ? container : null,
popularTags: this.isElement(tagsRoot) ? tagsRoot : null,
};
}
getElementById(id) {
if (!this.document || typeof this.document.getElementById !== "function") {
return null;
}
return this.document.getElementById(id) || null;
}
}