diff --git a/CHANGELOG.md b/CHANGELOG.md index a2a31f2..1fa1e72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 0.2.2 + +- Fixed a bug where the quote will not automatically update on the widget after updating the localStorage +- Fixed bug where the displayed quote will not be the same as the one in localStorage + ## 0.2.1 - Fixed quote category being change when the widget is manually refreshed when using Ūbersicht refresh all widget. (*This will persist the category until the refreshFrequency time is reached,if you want the old behavior refer to .jsx file to disable the new behavior*); diff --git a/quote-of-the-day.jsx b/quote-of-the-day.jsx index 2e4af9e..87cb9df 100644 --- a/quote-of-the-day.jsx +++ b/quote-of-the-day.jsx @@ -4,12 +4,12 @@ export const command = () => { * Index start at 0 *********************************************************************/ - const categories = ["death", "love", "life", "funny", "inspire", "art"]; + const categories = ["love", "life", "funny", "inspire", "art"]; /********************************************************************* * Set category here using Index number *********************************************************************/ - let current_category = categories[Math.floor(Math.random() * 6)]; + let current_category = categories[Math.floor(Math.random() * 5)]; /***************************************************************** * This part insures that the category does not change when @@ -33,6 +33,7 @@ export const command = () => { parseInt(nextCategoryOrQuoteUpdateTime) + parseInt(frequency) ); localStorage.setItem('currentCategory', current_category); + current_category = localStorage.getItem('currentCategory'); } } else { localStorage.setItem('nextCategoryOrQuoteUpdateTime', @@ -65,6 +66,10 @@ export const command = () => { // in case of first time running, open an issue on github or send error log console.log('Quote of the Day Error: ', error); }); + /********************************************************************* + * Extract quote from local storage + *********************************************************************/ + return JSON.parse(localStorage.getItem('quote_of_the_day')); } /********************************************************************* @@ -76,10 +81,6 @@ export const command = () => { export const refreshFrequency = 21600000; // This is use to set the category only when the widget is automatically refresh localStorage.setItem('refreshFrequency', refreshFrequency); -/********************************************************************* - * Extract quote from local storage - *********************************************************************/ -export const quote_of_the_day = JSON.parse(localStorage.getItem('quote_of_the_day')); /********************************************************************** * Style here @@ -172,16 +173,16 @@ export const className = }*/ `; -export const render = () => { +export const render = (data) => { return (
- {quote_of_the_day.quote} + {data.output.quote}- —{quote_of_the_day.author} - + —{data.output.author} +