Show empty message when no newsfeed items are available

This commit is contained in:
rejas 2021-12-20 13:29:56 +01:00
parent eae277f165
commit 2107e7c427
4 changed files with 10 additions and 2 deletions

View File

@ -121,7 +121,7 @@ Module.register("newsfeed", {
}
if (this.newsItems.length === 0) {
return {
loaded: false
empty: true
};
}
if (this.activeItem >= this.newsItems.length) {
@ -184,6 +184,7 @@ Module.register("newsfeed", {
const dateB = new Date(b.pubdate);
return dateB - dateA;
});
if (this.config.maxNewsItems > 0) {
newsItems = newsItems.slice(0, this.config.maxNewsItems);
}
@ -219,7 +220,6 @@ Module.register("newsfeed", {
}
//Remove selected tags from the end of rss feed items (title or description)
if (this.config.removeEndTags) {
for (let endTag of this.config.endTags) {
if (item.title.slice(-endTag.length) === endTag) {

View File

@ -54,6 +54,10 @@
{% endif %}
</div>
{% endif %}
{% elseif empty %}
<div class="small dimmed">
{{ "NEWSFEED_NO_ITEMS" | translate | safe }}
</div>
{% elseif error %}
<div class="small dimmed">
{{ "MODULE_CONFIG_ERROR" | translate({MODULE_NAME: "Newsfeed", ERROR: error}) | safe }}

View File

@ -31,6 +31,8 @@
"MODULE_CONFIG_CHANGED": "Die Konfigurationsoptionen für das {MODULE_NAME} Modul haben sich geändert. \nBitte überprüfen Sie die Dokumentation.",
"MODULE_CONFIG_ERROR": "Fehler im {MODULE_NAME} Modul. {ERROR}",
"NEWSFEED_NO_ITEMS": "Keine Neuigkeiten momentan.",
"UPDATE_NOTIFICATION": "Aktualisierung für MagicMirror² verfügbar.",
"UPDATE_NOTIFICATION_MODULE": "Aktualisierung für das {MODULE_NAME} Modul verfügbar.",
"UPDATE_INFO_SINGLE": "Die aktuelle Installation ist {COMMIT_COUNT} Commit hinter dem {BRANCH_NAME} Branch.",

View File

@ -35,6 +35,8 @@
"MODULE_ERROR_UNAUTHORIZED": "Authorization failed.",
"MODULE_ERROR_UNSPECIFIED": "Check logs for more details.",
"NEWSFEED_NO_ITEMS": "No news at the moment.",
"UPDATE_NOTIFICATION": "MagicMirror² update available.",
"UPDATE_NOTIFICATION_MODULE": "Update available for {MODULE_NAME} module.",
"UPDATE_INFO_SINGLE": "The current installation is {COMMIT_COUNT} commit behind on the {BRANCH_NAME} branch.",