mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-07 21:32:51 +00:00
Refactor video UI component orchestration
This commit is contained in:
1 parent
f579c965a7
commit
ad58ff04a3
5 files changed
+390
-88
No files matched your search
@@ -18,6 +18,7 @@ export class VideoListView {
|
||||
assets = {},
|
||||
state = {},
|
||||
utils = {},
|
||||
renderers = {},
|
||||
} = options;
|
||||
|
||||
this.document = doc;
|
||||
@@ -55,6 +56,13 @@ export class VideoListView {
|
||||
videosMap: state.videosMap instanceof Map ? state.videosMap : new Map(),
|
||||
};
|
||||
|
||||
this.renderers = {
|
||||
getLoadingMarkup:
|
||||
typeof renderers.getLoadingMarkup === "function"
|
||||
? renderers.getLoadingMarkup
|
||||
: () => "",
|
||||
};
|
||||
|
||||
this.utils = {
|
||||
dedupeVideos:
|
||||
typeof utils.dedupeVideos === "function"
|
||||
@@ -176,8 +184,28 @@ export class VideoListView {
|
||||
}
|
||||
}
|
||||
|
||||
destroy() {
|
||||
mount(container) {
|
||||
this.setContainer(container);
|
||||
return this.container;
|
||||
}
|
||||
|
||||
unmount() {
|
||||
this.setContainer(null);
|
||||
}
|
||||
|
||||
showLoading(message = "") {
|
||||
if (!this.container) {
|
||||
return;
|
||||
}
|
||||
|
||||
const markup = this.renderers.getLoadingMarkup(message);
|
||||
if (typeof markup === "string") {
|
||||
this.container.innerHTML = markup;
|
||||
}
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.unmount();
|
||||
this.teardownAllViewCountSubscriptions();
|
||||
this.renderedVideoIds.clear();
|
||||
this.videoCardInstances = [];
|
||||
|
||||
Reference in new issue
Block a user