Merge pull request #2734 from rejas/issue_2731

This commit is contained in:
Michael Teeuw 2021-12-20 19:41:31 +01:00 committed by GitHub
commit af6cf70558
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 52 additions and 2 deletions

View File

@ -22,6 +22,7 @@ _This release is scheduled to be released on 2022-01-01._
- Updated github actions.
- Replace spectron with playwright, update dependencies including electron update to v16.
- Added lithuanian language to translations.js
- Show info message if newsfeed is empty (fixes #2731)
### Fixed

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

@ -0,0 +1,28 @@
/* Magic Mirror Test config newsfeed module
*
* MIT Licensed.
*/
let config = {
timeFormat: 12,
modules: [
{
module: "newsfeed",
position: "bottom_bar",
config: {
feeds: [
{
title: "Rodrigo Ramirez Blog",
url: "http://localhost:8080/tests/configs/data/feed_test_rodrigoramirez.xml"
}
],
ignoreOldItems: true
}
}
]
};
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {
module.exports = config;
}

View File

@ -60,4 +60,17 @@ describe("Newsfeed module", function () {
expect(elem.textContent).toContain("Error in the Newsfeed module. Malformed url.");
});
});
describe("Ignore items", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/newsfeed/ignore_items.js");
helpers.getDocument(done, 3000);
});
it("should show empty items info message", function () {
const elem = document.querySelector(".newsfeed .small");
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("No news at the moment.");
});
});
});

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.",