refactoring newsfeed, moving hiding of module while loading away from dom-generation

This commit is contained in:
buxxi
2021-01-16 12:26:38 +01:00
parent 8538d83520
commit aaaf1f660c

View File

@@ -80,6 +80,9 @@ Module.register("newsfeed", {
this.generateFeed(payload); this.generateFeed(payload);
if (!this.loaded) { if (!this.loaded) {
if (this.config.hideLoading) {
this.show();
}
this.scheduleUpdateInterval(); this.scheduleUpdateInterval();
} }
@@ -144,18 +147,10 @@ Module.register("newsfeed", {
fullArticle.src = this.getActiveItemURL(); fullArticle.src = this.getActiveItemURL();
wrapper.appendChild(fullArticle); wrapper.appendChild(fullArticle);
} }
if (this.config.hideLoading) {
this.show();
}
} else {
if (this.config.hideLoading) {
this.hide();
} else { } else {
wrapper.innerHTML = this.translate("LOADING"); wrapper.innerHTML = this.translate("LOADING");
wrapper.className = "small dimmed"; wrapper.className = "small dimmed";
} }
}
return wrapper; return wrapper;
}, },
@@ -340,7 +335,9 @@ Module.register("newsfeed", {
notificationReceived: function (notification, payload, sender) { notificationReceived: function (notification, payload, sender) {
const before = this.activeItem; const before = this.activeItem;
if (notification === "ARTICLE_NEXT") { if (notification === "MODULE_DOM_CREATED" && this.config.hideLoading) {
this.hide();
} else if (notification === "ARTICLE_NEXT") {
this.activeItem++; this.activeItem++;
if (this.activeItem >= this.newsItems.length) { if (this.activeItem >= this.newsItems.length) {
this.activeItem = 0; this.activeItem = 0;