Skip to content

Commit af6cf70

Browse files
authored
Merge pull request #2734 from rejas/issue_2731
2 parents eae277f + 9b57e60 commit af6cf70

7 files changed

Lines changed: 52 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ _This release is scheduled to be released on 2022-01-01._
2222
- Updated github actions.
2323
- Replace spectron with playwright, update dependencies including electron update to v16.
2424
- Added lithuanian language to translations.js
25+
- Show info message if newsfeed is empty (fixes #2731)
2526

2627
### Fixed
2728

modules/default/newsfeed/newsfeed.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ Module.register("newsfeed", {
121121
}
122122
if (this.newsItems.length === 0) {
123123
return {
124-
loaded: false
124+
empty: true
125125
};
126126
}
127127
if (this.activeItem >= this.newsItems.length) {
@@ -184,6 +184,7 @@ Module.register("newsfeed", {
184184
const dateB = new Date(b.pubdate);
185185
return dateB - dateA;
186186
});
187+
187188
if (this.config.maxNewsItems > 0) {
188189
newsItems = newsItems.slice(0, this.config.maxNewsItems);
189190
}
@@ -219,7 +220,6 @@ Module.register("newsfeed", {
219220
}
220221

221222
//Remove selected tags from the end of rss feed items (title or description)
222-
223223
if (this.config.removeEndTags) {
224224
for (let endTag of this.config.endTags) {
225225
if (item.title.slice(-endTag.length) === endTag) {

modules/default/newsfeed/newsfeed.njk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@
5454
{% endif %}
5555
</div>
5656
{% endif %}
57+
{% elseif empty %}
58+
<div class="small dimmed">
59+
{{ "NEWSFEED_NO_ITEMS" | translate | safe }}
60+
</div>
5761
{% elseif error %}
5862
<div class="small dimmed">
5963
{{ "MODULE_CONFIG_ERROR" | translate({MODULE_NAME: "Newsfeed", ERROR: error}) | safe }}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* Magic Mirror Test config newsfeed module
2+
*
3+
* MIT Licensed.
4+
*/
5+
let config = {
6+
timeFormat: 12,
7+
8+
modules: [
9+
{
10+
module: "newsfeed",
11+
position: "bottom_bar",
12+
config: {
13+
feeds: [
14+
{
15+
title: "Rodrigo Ramirez Blog",
16+
url: "http://localhost:8080/tests/configs/data/feed_test_rodrigoramirez.xml"
17+
}
18+
],
19+
ignoreOldItems: true
20+
}
21+
}
22+
]
23+
};
24+
25+
/*************** DO NOT EDIT THE LINE BELOW ***************/
26+
if (typeof module !== "undefined") {
27+
module.exports = config;
28+
}

tests/e2e/modules/newsfeed_spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,17 @@ describe("Newsfeed module", function () {
6060
expect(elem.textContent).toContain("Error in the Newsfeed module. Malformed url.");
6161
});
6262
});
63+
64+
describe("Ignore items", function () {
65+
beforeAll(function (done) {
66+
helpers.startApplication("tests/configs/modules/newsfeed/ignore_items.js");
67+
helpers.getDocument(done, 3000);
68+
});
69+
70+
it("should show empty items info message", function () {
71+
const elem = document.querySelector(".newsfeed .small");
72+
expect(elem).not.toBe(null);
73+
expect(elem.textContent).toContain("No news at the moment.");
74+
});
75+
});
6376
});

translations/de.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
"MODULE_CONFIG_CHANGED": "Die Konfigurationsoptionen für das {MODULE_NAME} Modul haben sich geändert. \nBitte überprüfen Sie die Dokumentation.",
3232
"MODULE_CONFIG_ERROR": "Fehler im {MODULE_NAME} Modul. {ERROR}",
3333

34+
"NEWSFEED_NO_ITEMS": "Keine Neuigkeiten momentan.",
35+
3436
"UPDATE_NOTIFICATION": "Aktualisierung für MagicMirror² verfügbar.",
3537
"UPDATE_NOTIFICATION_MODULE": "Aktualisierung für das {MODULE_NAME} Modul verfügbar.",
3638
"UPDATE_INFO_SINGLE": "Die aktuelle Installation ist {COMMIT_COUNT} Commit hinter dem {BRANCH_NAME} Branch.",

translations/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
"MODULE_ERROR_UNAUTHORIZED": "Authorization failed.",
3636
"MODULE_ERROR_UNSPECIFIED": "Check logs for more details.",
3737

38+
"NEWSFEED_NO_ITEMS": "No news at the moment.",
39+
3840
"UPDATE_NOTIFICATION": "MagicMirror² update available.",
3941
"UPDATE_NOTIFICATION_MODULE": "Update available for {MODULE_NAME} module.",
4042
"UPDATE_INFO_SINGLE": "The current installation is {COMMIT_COUNT} commit behind on the {BRANCH_NAME} branch.",

0 commit comments

Comments
 (0)