Skip to content

Commit

Permalink
Merge pull request #3 from stoneC0der/dev
Browse files Browse the repository at this point in the history
Fixed bug where the quote will not automatically update when the time is due
  • Loading branch information
stoneC0der authored May 23, 2021
2 parents e2e3857 + b5efd9e commit 2beaea0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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*);
Expand Down
23 changes: 12 additions & 11 deletions quote-of-the-day.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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',
Expand Down Expand Up @@ -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'));
}

/*********************************************************************
Expand All @@ -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
Expand Down Expand Up @@ -172,16 +173,16 @@ export const className =
}*/
`;

export const render = () => {
export const render = (data) => {
return (
<div className="quote-of-the-day-container">
<div className="quote-of-the-day">
<h5 className="title">{quote_of_the_day.title}</h5>
<h5 className="title">{data.output.title}</h5>
<blockquote className="quote" cite="https://quotes.rest/qod">
{quote_of_the_day.quote}
{data.output.quote}
</blockquote>
<cite className="author">{quote_of_the_day.author}</cite>
<img className="image" src={quote_of_the_day.background} />
<cite className="author">{data.output.author}</cite>
<img className="image" src={data.output.background} />
</div>
</div>
);
Expand Down
Binary file modified quote-of-the-day.widget.zip
Binary file not shown.

0 comments on commit 2beaea0

Please sign in to comment.