Added a runtime var isShowingDescription that gets reset to user config.
this.config.showDescription no longer mutates during runtime.
Changelog has been updated to include this fix.
This commit is contained in:
Edward Shen 2018-05-15 20:32:02 -04:00
parent 349af24c81
commit 55a161fafe
No known key found for this signature in database
GPG Key ID: 4E887A42793D0433
2 changed files with 9 additions and 7 deletions

View File

@ -26,6 +26,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Fixed browser-side code to work on the Midori browser. - Fixed browser-side code to work on the Midori browser.
- Fixed issue where heat index was reporting incorrect values in Celsius and Fahrenheit. [#1263](https://github.com/MichMich/MagicMirror/issues/1263) - Fixed issue where heat index was reporting incorrect values in Celsius and Fahrenheit. [#1263](https://github.com/MichMich/MagicMirror/issues/1263)
- Fixed weatherforecast to use dt_txt field instead of dt to handle timezones better - Fixed weatherforecast to use dt_txt field instead of dt to handle timezones better
- newsfeed now remembers to show the description when `"ARTICLE_LESS_DETAILS"` is called if the user wants to always show the description. [#1282](https://github.com/MichMich/MagicMirror/issues/1282)
### Updated ### Updated
- Updated Italian translation - Updated Italian translation

View File

@ -67,6 +67,7 @@ Module.register("newsfeed",{
this.registerFeeds(); this.registerFeeds();
this.isShowingDescription = this.config.showDescription;
}, },
// Override socket notification handler. // Override socket notification handler.
@ -133,7 +134,7 @@ Module.register("newsfeed",{
if (this.config.removeStartTags == "description" || this.config.removeStartTags == "both") { if (this.config.removeStartTags == "description" || this.config.removeStartTags == "both") {
if (this.config.showDescription) { if (this.isShowingDescription) {
for (f=0; f<this.config.startTags.length;f++) { for (f=0; f<this.config.startTags.length;f++) {
if (this.newsItems[this.activeItem].description.slice(0,this.config.startTags[f].length) == this.config.startTags[f]) { if (this.newsItems[this.activeItem].description.slice(0,this.config.startTags[f].length) == this.config.startTags[f]) {
this.newsItems[this.activeItem].title = this.newsItems[this.activeItem].description.slice(this.config.startTags[f].length,this.newsItems[this.activeItem].description.length); this.newsItems[this.activeItem].title = this.newsItems[this.activeItem].description.slice(this.config.startTags[f].length,this.newsItems[this.activeItem].description.length);
@ -152,7 +153,7 @@ Module.register("newsfeed",{
} }
} }
if (this.config.showDescription) { if (this.isShowingDescription) {
for (f=0; f<this.config.endTags.length;f++) { for (f=0; f<this.config.endTags.length;f++) {
if (this.newsItems[this.activeItem].description.slice(-this.config.endTags[f].length)==this.config.endTags[f]) { if (this.newsItems[this.activeItem].description.slice(-this.config.endTags[f].length)==this.config.endTags[f]) {
this.newsItems[this.activeItem].description = this.newsItems[this.activeItem].description.slice(0,-this.config.endTags[f].length); this.newsItems[this.activeItem].description = this.newsItems[this.activeItem].description.slice(0,-this.config.endTags[f].length);
@ -169,7 +170,7 @@ Module.register("newsfeed",{
wrapper.appendChild(title); wrapper.appendChild(title);
} }
if (this.config.showDescription) { if (this.isShowingDescription) {
var description = document.createElement("div"); var description = document.createElement("div");
description.className = "small light" + (!this.config.wrapDescription ? " no-wrap" : ""); description.className = "small light" + (!this.config.wrapDescription ? " no-wrap" : "");
var txtDesc = this.newsItems[this.activeItem].description; var txtDesc = this.newsItems[this.activeItem].description;
@ -323,7 +324,7 @@ Module.register("newsfeed",{
}, },
resetDescrOrFullArticleAndTimer: function() { resetDescrOrFullArticleAndTimer: function() {
this.config.showDescription = false; this.isShowingDescription = this.config.showDescription;
this.config.showFullArticle = false; this.config.showFullArticle = false;
this.scrollPosition = 0; this.scrollPosition = 0;
// reset bottom bar alignment // reset bottom bar alignment
@ -366,8 +367,8 @@ Module.register("newsfeed",{
} }
// display full article // display full article
else { else {
this.config.showDescription = !this.config.showDescription; this.isShowingDescription = !this.isShowingDescription;
this.config.showFullArticle = !this.config.showDescription; this.config.showFullArticle = !this.isShowingDescription;
// make bottom bar align to top to allow scrolling // make bottom bar align to top to allow scrolling
if(this.config.showFullArticle == true){ if(this.config.showFullArticle == true){
document.getElementsByClassName("region bottom bar")[0].style.bottom = "inherit"; document.getElementsByClassName("region bottom bar")[0].style.bottom = "inherit";
@ -375,7 +376,7 @@ Module.register("newsfeed",{
} }
clearInterval(timer); clearInterval(timer);
timer = null; timer = null;
Log.info(this.name + " - showing " + this.config.showDescription ? "article description" : "full article"); Log.info(this.name + " - showing " + this.isShowingDescription ? "article description" : "full article");
this.updateDom(100); this.updateDom(100);
} }
} else if(notification == "ARTICLE_SCROLL_UP"){ } else if(notification == "ARTICLE_SCROLL_UP"){